class Core(Object): def __init__(self): from core.data import ThreadCollection self.launched_apps = ThreadCollection({}) def launch(self, argv): try: if len(argv) > 1: if len(argv) > 2: getattr(self, argv[1])(argv[2:]) else: getattr(self, argv[1])([]) else: self.console() except Exception as e: print(e) def console(self): print('Console management :') cmd = '' while (cmd != 'exit'): if cmd != '': self.launch(['manage.py'] + cmd.split(' ')) cmd = input('>>> ') print('Stoping... Bye !') def start(self, args): base_name = args[0] if len(args) else settings.PROJECT['main'] app_main = Application.get_app_main(base_name) if os.path.isfile(app_main): application = Application.launch(base_name) th = threading.Thread(target=application, name=base_name) self.launched_apps.add(th).start(base_name) return True else: print('Error : ' + app_main + ' doesn\'t exists') return False def create(self, args): base_name = args[0] print('Creating directory ' + Application.get_app_dir(base_name)) os.makedirs(Application.get_app_dir(base_name)) os.makedirs(Application.get_app_dir(base_name) + DS + 'model') os.makedirs(Application.get_app_dir(base_name) + DS + 'view') os.makedirs(Application.get_app_dir(base_name) + DS + 'controller') os.makedirs(Application.get_app_dir(base_name) + DS + 'assets') print('Creating file ' + Application.get_app_main(base_name)) main = open(Application.get_app_main(base_name), 'w') settings = open( Application.get_app_dir(base_name) + 'settings.py', 'w') mainviewcontroller = open( Application.get_app_dir(base_name) + 'controller' + DS + 'MainViewController.py', 'w') main.write(TemplateManager.fill_main(base_name)) settings.write(TemplateManager.fill_settings(base_name)) mainviewcontroller.write(TemplateManager.fill_mainviewcontroller()) main.close() settings.close() print('Done.') return True
class Core(Object): def __init__(self): from core.data import ThreadCollection self.launched_apps = ThreadCollection({}) def launch(self, argv): try: if len(argv) > 1: if len(argv) > 2: getattr(self, argv[1])(argv[2:]) else: getattr(self, argv[1])([]) else: self.console(); except Exception as e: print(e) def console(self): print('Console management :'); cmd = '' while(cmd != 'exit'): if cmd != '': self.launch(['manage.py'] + cmd.split(' ')) cmd = input('>>> ') print('Stoping... Bye !') def start(self, args): base_name = args[0] if len(args) else settings.PROJECT['main'] app_main = Application.get_app_main(base_name); if os.path.isfile(app_main): application = Application.launch(base_name) th = threading.Thread(target=application,name=base_name) self.launched_apps.add(th).start(base_name) return True else: print('Error : ' + app_main + ' doesn\'t exists') return False def create(self, args): base_name = args[0] print('Creating directory ' + Application.get_app_dir(base_name)) os.makedirs(Application.get_app_dir(base_name)) os.makedirs(Application.get_app_dir(base_name) + DS + 'model') os.makedirs(Application.get_app_dir(base_name) + DS + 'view') os.makedirs(Application.get_app_dir(base_name) + DS + 'controller') os.makedirs(Application.get_app_dir(base_name) + DS + 'assets') print('Creating file ' + Application.get_app_main(base_name)) main = open(Application.get_app_main(base_name), 'w') settings = open(Application.get_app_dir(base_name) + 'settings.py', 'w') mainviewcontroller = open(Application.get_app_dir(base_name) + 'controller' + DS + 'MainViewController.py', 'w') main.write(TemplateManager.fill_main(base_name)) settings.write(TemplateManager.fill_settings(base_name)) mainviewcontroller.write(TemplateManager.fill_mainviewcontroller()) main.close() settings.close() print('Done.') return True
def __init__(self): from core.data import ThreadCollection self.launched_apps = ThreadCollection({})