def execute(self, args=None): if not args: logging.error('specify a command to create.') return command = args[0] os.makedirs(join(join(alePath('recipes_all'), command), 'commands')) init1Path = join(join(join(alePath('recipes_all'), command), '__init__.py')) init2Path = join(join(join(alePath('recipes_all'), command), 'commands'), '__init__.py') commandPath = join(join(join(alePath('recipes_all'), command), 'commands'), '%s.py' % command) initContent = """ #!/usr/bin/env python # encoding: utf-8 """ FILE = open(init1Path, 'w') FILE.write(initContent) FILE.close() FILE = open(init2Path, 'w') FILE.write(initContent) FILE.close() FILE = open(commandPath, 'w') FILE.write('''#!/usr/bin/python # -*- coding: utf-8 -*- import os from os.path import join as join from ale.base import Command ''') FILE.write('class %sCommand(Command):\n' % command) FILE.write(" name = '%s'\n" % command) FILE.write(""" shorthelp = 'put a short description of what the command does here' def execute(self, args=None): print 'Insert python code to do whatever the task needs to do. Take a look at some of the other tasks (**/commands/*.py) for guidance.' os.system('echo echo echo echo') return 0 # error count (0=success). ## defining install is optional # def install(self, args=None): # pass """) FILE.close() os.system(os.environ['EDITOR'] + ' ' + commandPath) print 'Created comand: %s at %s' % (command, commandPath) print 'It is currently _not_ recipes_installed. Install with "ale install <command>"'
def execute(self, args=None): if not args: print 'Syntax: ale gae [subcommand]' print ' Available subcommands:' print ' start -- start the local dev_appserver and launch browser' print ' deploy -- deploy to the hosted gae app and launch browser' print ' dash -- open the dashboard for the hosted gae app' print ' log -- open the dashboard (on logs tab) for hosted gae app' print ' data -- open the dashboard (on data tab) for hosted gae app' print ' doc -- open the gae python docs' print ' remoteshell -- open a shell to the remote, deployed app' return if args and args[0].lower() == 'start': p = Popen('%s/google_appengine/dev_appserver.py --allow_skipped_files .' % extractPath, shell=True) import time time.sleep(4) # todo: just do a fetch ourself to check when it has finished coming up...? Popen('open' + ' http://localhost:8080', shell=True) sts = os.waitpid(p.pid, 0)[1] elif args and args[0].lower() == 'deploy': appId = getAppId() os.system('%s/google_appengine/appcfg.py update .' % extractPath) os.system('open http://%s.appspot.com' % appId) elif args and args[0].lower() == 'dash': appId = getAppId() if appId: os.system('open http://appengine.google.com/dashboard?app_id=%s' % appId) elif args and args[0].lower() == 'log': appId = getAppId() if appId: os.system('open http://appengine.google.com/logs?app_id=%s' % appId) elif args and args[0].lower() == 'data': appId = getAppId() if appId: os.system('open http://appengine.google.com/datastore/explorer?app_id=%s' % appId) elif args and args[0].lower() == 'doc': os.system('open http://code.google.com/appengine/docs/python/') elif args and args[0].lower() == 'remoteshell': appId = getAppId() logging.info("Starting remoteshell for app: %s. Careful you are working against your _live_ deployed app! " % appId) fullcommandwithargs = ['python', alePath("recipes_installed/gae/pkgs/google_appengine_1.3.1/google_appengine/") + 'remote_api_shell.py', appId] p = Popen(fullcommandwithargs, env={'PYTHONPATH': os.environ['PYTHONPATH'] + ':lib:.', 'PATH': os.environ['PATH']}) # todo: just yield a generator or get all .py files sts = os.waitpid(p.pid, 0)[1] else: logging.error('unknown command: %s' % args[0])
def install(self, args=None): downloadAndExtract('ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip', finalJslintDir) download('http://www.jslint.com/rhino/jslint.js', 'jslint.js') shutil.move(join(alePath('tmp'), 'jslint.js'), finalJslintPath)
def jslint(file): tmpFile = join(alePath('tmp'), os.path.split(file)[1] + '_tmp') command = 'java -classpath %s org.mozilla.javascript.tools.shell.Main %s %s' % (finalRhinoJsJar, finalJslintPath, file) logging.info('Jslint checking %s' % file) return os.system(command)
#!/usr/bin/python # -*- coding: utf-8 -*- import os from os.path import join as join from ale.base import Command from ale.aleconfig import alePath from utils import downloadAndExtract, recurse, download import shutil import logging finalJslintDir = join(os.path.join(alePath('recipes_installed'), 'jslint'), 'pkgs') finalJslintPath = join(finalJslintDir, 'jslint.js') finalRhinoJsJar = join(finalJslintDir, 'rhino1_7R2/js.jar') class jslintCommand(Command): name = 'jslint' shorthelp = 'run jslint against all the .js files in the project' def execute(self, args=None): def jslint(file): tmpFile = join(alePath('tmp'), os.path.split(file)[1] + '_tmp') command = 'java -classpath %s org.mozilla.javascript.tools.shell.Main %s %s' % (finalRhinoJsJar, finalJslintPath, file) logging.info('Jslint checking %s' % file) return os.system(command)
# -*- coding: utf-8 -*- import os import re import logging from os.path import join as join from utils import downloadAndExtract, gitignore from ale.aleconfig import alePath from ale.base import Command from subprocess import Popen gaefile = 'google_appengine_1.3.1.zip' gaeversion = 'google_appengine_1.3.1' remotePath = '%s%s' % ('http://googleappengine.googlecode.com/files/', gaefile) extractPath = join(join(join(alePath('recipes_installed'), 'gae'), 'pkgs'), gaeversion) class NoApplicationFoundNoAppYamlHere(Exception): pass def getAppId(): if not os.path.exists('app.yaml'): logging.error('No app engine application lives here. (no app.yaml).') raise NoApplicationFoundNoAppYamlHere p = re.compile('application: (.*)') appyamllines = open('app.yaml').read().split('\n') appId = None for line in appyamllines:
#!/usr/bin/python # -*- coding: utf-8 -*- import os from os.path import join as join from ale.base import Command from ale.aleconfig import alePath from ale.utils import downloadAndExtract djangofile = 'app-engine-patch-1.1RC.zip' djangoversion = 'app-engine-patch-1.1RC' remotePath = '%s%s' % ('http://app-engine-patch.googlecode.com/files/', djangofile) extractPath = join(join(join(alePath('recipes_installed'), 'django'), 'pkgs'), djangoversion) class DjangoCommand(Command): name = 'django' tags = 'experimental' shorthelp = \ 'Experimental: django app engine patch. Install sample project to currentdirectory -- overwrites stuff! careful!' def execute(self, args=None): print 'Insert python code to do whatever the task needs to do. Take a look at some of the other tasks (**/commands/*.py) for guidance.' os.system('echo echo echo echo') return 0 def install(self, args=None): downloadAndExtract(remotePath, extractPath) os.system('mv -i %s/* .' % join(extractPath, 'app-engine-patch-sample'))