Exemplo n.º 1
0
Arquivo: gae.py Projeto: mattorb/Ale
 def install(self, args=None):
     downloadAndExtract(remotePath, extractPath)
     os.system('chmod +x %s' % join(join(extractPath, 'google_appengine'), 'dev_appserver.py'))
     os.system('chmod +x %s' % join(join(extractPath, 'google_appengine'), 'appcfg.py'))
     gitignore('*.pyc')
     gitignore('.DS_Store')
     gitignore('.Trashes')
     gitignore('.fseventsd')
Exemplo n.º 2
0
Arquivo: test.py Projeto: mattorb/Ale
    def install(self, args=None):
        extractPath = os.path.join(os.path.join(alePath('recipes_installed'), 'test'), 'pkgs')

        downloadAndExtract('http://python-nose.googlecode.com/files/nose-0.11.0.tar.gz', extractPath)
        downloadAndExtract('http://pypi.python.org/packages/source/c/coverage/coverage-3.2b3.tar.gz', extractPath)

        coverPyPath = join(alePath('recipes_installed/test/pkgs/nose-0.11.0/nose/plugins'), 'cover.py')
        patch1Path = join(alePath('recipes_all/test/'), 'excludecoveragepatch.patch')
        patch2Path = join(alePath('recipes_all/test/'), 'excludenosepatch.patch')

        logging.info('Patching coverage plugin...')
        os.system('patch %s %s' % (coverPyPath, patch1Path))
        os.system('patch %s %s' % (coverPyPath, patch2Path))

        logging.info('Adding to .gitignore...')
        gitignore('.coverage')
Exemplo n.º 3
0
    def execute(self, args=None):
        validTemplateNames = ['helloworld', 'helloworldwebapp', 'pale'] + customStarterApps
        if not args:
            print self.shorthelp
            print 'available app templates:'
            print 'helloworld           -- simple helloworld app'
            print 'helloworldwebapp     -- simple helloworld app using webapp fmk'
            print 'xmppsendandreply     -- simple xmpp (instant message) send and reply'
            print 'emailreceive         -- simple e-mail receive example'
            print 'emailsendui          -- simple e-mail send example'
            print 'deferredemail        -- simple deferred lib queued e-mail send example'
            print 'starter_pale         -- a basic project layout with buckets for most things you could want and an import fix built in'
        else:
            templateName = args[0].lower()

            if templateName not in validTemplateNames:
                print 'Unknown app name %s' % args[0]
                return
            if templateName in customStarterApps:
                tarballurl = 'http://github.com/mpstx/appengine_py_%s/tarball/master' % templateName
                tmpPath = join(join(alePath('tmp'), templateName + '.tar.gz'))
                download(tarballurl, '%s.tar.gz' % templateName)
                logging.info("Extracting %s here" % templateName)
                os.system('tar xzf %s --strip 1 -C .' % tmpPath)
            elif templateName == 'helloworld':
                logging.info('creating ./helloworld.py')
                FILE = open('./helloworld.py', 'w')
                FILE.write("""
print 'Content-Type: text/plain'
print ''
print 'Hello, world!  This is a bare bones app engine application'
""")
                FILE.close()

                logging.info('creating ./app.yaml')
                FILE = open('./app.yaml', 'w')
                FILE.write("""
application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py        
            """)
                FILE.close()
            elif templateName == 'helloworldwebapp':
                logging.info('creating ./helloworld.py')
                FILE = open('./helloworld.py', 'w')
                FILE.write("""
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')

application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
""")
                FILE.close()

                logging.info('creating ./app.yaml')
                FILE = open('./app.yaml', 'w')
                FILE.write("""
application: helloworldwebapp
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py        
""")
                FILE.close()
            else:
                pkgPath = join(join(alePath('recipes_installed'), 'createapp'), 'pkgs')
                templateZipPath = join(pkgPath, '%s.zip' % templateName)

                if os.path.exists(templateZipPath):
                    extract(templateZipPath, '.')
                    gitignore('tmp')
                else:
                    logging.error('Could not find template: %s' % templateName)
                    return

            return 0