def post(self):
        global applications
        #self.redirect('/applications/'+str(applications[-1].id), permanent=True)
        #self.render('templates/upload.html')
        try:
            app_name = 'application' + str(len(applications))
            app_id = hashlib.md5(app_name).hexdigest()

            # copy base for the new application
            logging.info('creating application...')
            copyAnything(BASE_DIR, os.path.join(APP_DIR, app_id))

            app = WuApplication(id=app_id,
                                name=app_name,
                                dir=os.path.join(APP_DIR, app_id))
            applications.append(app)

            # dump config file to app
            logging.info('saving application configuration...')
            app.saveConfig()

            self.content_type = 'application/json'
            self.write({'status': 0, 'app': app.config()})
        except Exception as e:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            print traceback.print_exception(exc_type,
                                            exc_value,
                                            exc_traceback,
                                            limit=2,
                                            file=sys.stdout)
            self.content_type = 'application/json'
            self.write({'status': 1, 'mesg': 'Cannot create application'})
示例#2
0
def load_app_from_dir(dir):
  app = WuApplication(dir=dir)
  app.loadConfig()
  return app