def test_compile(self): #apps = ['welcome', 'admin', 'examples'] apps = ['welcome'] for appname in apps: appname_path = os.path.join(os.getcwd(), 'applications', appname) compile_application(appname_path) remove_compiled_application(appname_path) test_path = os.path.join(os.getcwd(), "%s.w2p" % appname) unpack_path = os.path.join(os.getcwd(), 'unpack', appname) w2p_pack(test_path, appname_path, compiled=True, filenames=None) w2p_pack(test_path, appname_path, compiled=False, filenames=None) w2p_unpack(test_path, unpack_path) return
def compile_app(): """ Compile the application """ app = request.args[0] folder = apath(app) try: compile_application(folder) session.flash = T('application compiled') except (Exception, RestrictedError), e: remove_compiled_application(folder) msg = 'cannot compile. there are errors in your app. run it to debug it' msg = T(msg) session.flash = msg
def test_compile(self): cwd = os.getcwd() app_path = os.path.join(cwd, 'applications', test_app_name) self.assertIsNone(compile_application(app_path)) remove_compiled_application(app_path) test_pack = os.path.join(cwd, "%s.w2p" % test_app_name) w2p_pack(test_pack, app_path, compiled=True, filenames=None) w2p_pack(test_pack, app_path, compiled=False, filenames=None) global test_unpack_dir test_unpack_dir = tempfile.mkdtemp() w2p_unpack(test_pack, test_unpack_dir)
def widget(self): request=self.environment.request response=self.environment.response T=self.environment.T form=SQLFORM(self.db.innoinfo,1,showid=False,col3={ 'InnoCompiler':'The full path of your Inno compiler. e.g. C:\Program Files\Inno Setup 5\Compil32.exe', 'AppName':'e.g. My App', 'AppVerName':'e.g. My App 1.0', 'DefaultDirName':'No space allowed. E.g. {sd}\MY_COMPANY\MY_APP', 'DisableDirPage':'You might not want users to choose a directory that might break your app.',}) if form.accepts(request,keepvalues=True): try: compile_application(request.folder) except (Exception, RestrictedError), e: response.flash = T('cannot compile. there are errors in your app. run it to debug it') else: codecs.open(os.path.join(request.folder,'cache','license.inno'),'w',self.InnoEncoding).write( codecs.open(os.path.join(request.folder,'license'),'r','utf8').read()) codecs.open(os.path.join(request.folder,'cache','about.inno'),'w',self.InnoEncoding).write( codecs.open(os.path.join(request.folder,'about'),'r','utf8').read()) open(os.path.join(request.folder,'cache','default.py'),'w').write(''' def index(): redirect(URL(a='%s',c='default',f='index')) # Use this file to override the webcome/controllers/default.py '''.strip()%request.application) data={'application':request.application} data.update(request.vars) open(os.path.join(request.folder,'cache','setup.iss'),'wb').write(self.template%data) ret=os.system('"%s"/cc applications\%s\cache\setup.iss' %(request.vars.InnoCompiler,request.application)) if ret: response.flash=T('Inno Compile Error: %d'%ret) else: response.flash = T('application compiled') response.headers['Content-disposition']="attachment;filename=%s_setup.exe"%request.application return response.stream(open(os.path.join(request.env.web2py_path, 'Output','setup.exe'),'rb'),chunk_size=4096) finally: remove_compiled_application(request.folder)
def app_compile(app, request, skip_failed_views=False): """Compiles the application Args: app(str): application name request: the global request object Returns: None if everything went ok, traceback text if errors are found """ from gluon.compileapp import compile_application, remove_compiled_application folder = apath(app, request) try: failed_views = compile_application(folder, skip_failed_views) return failed_views except (Exception, RestrictedError): tb = traceback.format_exc() remove_compiled_application(folder) return tb
def widget(self): request = self.environment.request response = self.environment.response T = self.environment.T form = SQLFORM( self.db.innoinfo, 1, showid=False, col3={ 'InnoCompiler': 'The full path of your Inno compiler. e.g. C:\Program Files\Inno Setup 5\Compil32.exe', 'AppName': 'e.g. My App', 'AppVerName': 'e.g. My App 1.0', 'DefaultDirName': 'No space allowed. E.g. {sd}\MY_COMPANY\MY_APP', 'DisableDirPage': 'You might not want users to choose a directory that might break your app.', }) if form.accepts(request, keepvalues=True): try: compile_application(request.folder) except (Exception, RestrictedError), e: response.flash = T( 'cannot compile. there are errors in your app. run it to debug it' ) else: codecs.open( os.path.join(request.folder, 'cache', 'license.inno'), 'w', self.InnoEncoding).write( codecs.open(os.path.join(request.folder, 'license'), 'r', 'utf8').read()) codecs.open( os.path.join(request.folder, 'cache', 'about.inno'), 'w', self.InnoEncoding).write( codecs.open(os.path.join(request.folder, 'about'), 'r', 'utf8').read()) open(os.path.join(request.folder, 'cache', 'default.py'), 'w').write(''' def index(): redirect(URL(a='%s',c='default',f='index')) # Use this file to override the webcome/controllers/default.py '''.strip() % request.application) data = {'application': request.application} data.update(request.vars) open(os.path.join(request.folder, 'cache', 'setup.iss'), 'wb').write(self.template % data) ret = os.system( '"%s"/cc applications\%s\cache\setup.iss' % (request.vars.InnoCompiler, request.application)) if ret: response.flash = T('Inno Compile Error: %d' % ret) else: response.flash = T('application compiled') response.headers[ 'Content-disposition'] = "attachment;filename=%s_setup.exe" % request.application return response.stream(open( os.path.join(request.env.web2py_path, 'Output', 'setup.exe'), 'rb'), chunk_size=4096) finally:
]: location = current.deployment_settings.get_template_location() if exists( join(folder, location, "templates", theme, "views", "_%s" % view)): views[view] = "../%s/templates/%s/views/_%s" % (location, theme, view) def apath(path="", r=None): """ Builds a path inside an application folder Parameters ---------- path: path within the application folder r: the global request object """ opath = up(r.folder) while path[:3] == "../": (opath, path) = (up(opath), path[3:]) return join(opath, path).replace("\\", "/") folder = apath(app, request) compile_application(folder)
def test_index_compiled(self): appname_path = os.path.join(os.getcwd(), 'applications', 'welcome') compile_application(appname_path) self._test_index() remove_compiled_application(appname_path)
def compile(self): """ Compile the Eden code """ # Load the base Model self.run_model() from gluon.fileutils import up request = current.request os_path = os.path join = os_path.join # Pass View Templates to Compiler settings = current.deployment_settings s3 = current.response.s3 s3.views = views = {} s3.theme = theme = settings.get_theme() if theme != "default": folder = request.folder location = settings.get_template_location() exists = os_path.exists for view in ["create.html", #"delete.html", "display.html", "iframe.html", "list.html", "list_filter.html", "map.html", #"merge.html", "plain.html", "popup.html", "profile.html", "report.html", #"review.html", "summary.html", #"timeplot.html", "update.html", ]: if exists(join(folder, location, "templates", theme, "views", "_%s" % view)): views[view] = "../%s/templates/%s/views/_%s" % (location, theme, view) def apath(path="", r=None): """ Builds a path inside an application folder Parameters ---------- path: path within the application folder r: the global request object """ opath = up(r.folder) while path[:3] == "../": (opath, path) = (up(opath), path[3:]) return join(opath, path).replace("\\", "/") folder = apath(request.application, request) compile_application(folder)
"list_create.html", "map.html", "report.html", "search.html", "update.html", ]: if exists(join(folder, "private", "templates", theme, "views", "_%s" % view)): views[view] = "../private/templates/%s/views/_%s" % (theme, view) def apath(path="", r=None): """ Builds a path inside an application folder Parameters ---------- path: path within the application folder r: the global request object """ opath = up(r.folder) while path[:3] == "../": (opath, path) = (up(opath), path[3:]) return join(opath, path).replace("\\", "/") folder = apath(app, request) compile_application(folder)
# -*- coding: utf-8 -*- import sys import os path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'web2py') sys.path = [path] + [p for p in sys.path if not p == path] from gluon.compileapp import compile_application compile_application(os.path.join(path, 'applications', 'standard')) compile_application(os.path.join(path, 'applications', 'optimized'))
# -*- coding: utf-8 -*- import sys import os path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "web2py") sys.path = [path] + [p for p in sys.path if not p == path] from gluon.compileapp import compile_application compile_application(os.path.join(path, "applications", "standard")) compile_application(os.path.join(path, "applications", "optimized"))