Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,44 @@ def check_and_create(fileName, templates, templateName, emoji='', vars={}):
else:
print('Found. ✅')

def get_main_name():
files=os.listdir()
fileName=[]
for file in files:
if file[-2:]=='py':
fileName.append(file)
else:
pass

if len(fileName) == 1:
return fileName[0]
elif len(fileName)==0:
print('You do not have py file in this directory, please go into the correct directory')
else:
if 'main.py' in fileName:
return 'main.py'
else:
print()
for file in fileName:
print(file)

file=input('there are too many py files are in this directory, please choose one of them as the main file: ')

if not file in fileName:
print('You do not have any file with this name')
elif file in fileName:
return file

def get_main():
if not doesFileExist('main.py'):
print('Not found ❌')
# TODO: get main file's name
raise NameError('Couldnt found main')
mainFileName=get_main_name()

if doesFileExist(mainFileName):
print(f'{mainFileName} Present. ✅')
return mainFileName
else:
print('Present. ✅')
return 'main.py'
print('Not found ❌')
raise NameError('Couldnt found main')



def build_image(org='', repo='gepp', tag='latest'):
Expand Down Expand Up @@ -440,13 +469,35 @@ def main(interactive):
##### Main session #####
print('🙌 GEPP Starting!')

print('📍 Locating main.py file... ', end='')

if interactive:
config = get_interactive_config()
else:
config = generate_default_config()

'''
TODO: fix here to include prompt toolkit and get a list of ports

listening = prompt(
"Is the app listening additional ports (for exposing metrics, healthchecks etc.)?")

if listening:
print("it is listening!")
'''

print('📍 Locating main file... ', end='')


try:
mainFile = get_main()
except:
print('Could not get main.py, exiting.')
import sys
sys.exit(1)

templates = jinja2.Environment(
loader=jinja2.PackageLoader(package_name=mainFile[:-3]), autoescape=True)

tempVars['mainFile'] = mainFile

if interactive:
Expand Down