コード例 #1
0
    def __call__(self):
        c = self.context

        config, app_id, app_version = Site.ResolveConfig(
            c,
            c.options.config,
            site_dir=c.options.site_dir,
            host=c.options.host)

        print config
        return True
コード例 #2
0
    def appengine_logs_url(self):
        c = self.context

        if not c.options.host:
            return ""

        site_config, appengine_app_id, appengine_app_version = None, None, None

        try:
            site_config, appengine_app_id, appengine_app_version = Site.ResolveConfig(
                c, c.options.config, c.options.site_dir, c.options.host)
        except:
            #We really don't care if we found a config, speedtests can be run on arbitrary hosts.
            pass

        if not appengine_app_id:
            return None

        self._ae_logs_params["app_id"] = appengine_app_id
        self._ae_logs_params[
            "filter"] = self._ae_logs_params["filter"] % self.runid

        return "%s?%s" % (self._ae_dashboard,
                          urllib.urlencode(self._ae_logs_params))
コード例 #3
0
    def __call__(self):

        c = self.context
        site = Site.Get(c)
        acre = Acre.Get(c)

        config, app_id, app_version = Site.ResolveConfig(
            c, c.options.config, c.options.site_dir, c.options.host)

        if not site:
            return c.error(
                "Could not figure out location of site. You can specify --site_dir as an option, or run the script from within a site svn checkout directory structure to figure it out automatically."
            )

        if not acre:
            return c.error(
                "Could not get an acre instance. You can specifiy --acre_dir, or --acre_version with a valid acre branch or trunk"
            )

        if not config:
            return c.error(
                "You have to specify an acre build target with -c e.g. -c sandbox-freebasesite or a host with --host e.g. --host dev.sandbox-freebase.com"
            )

        (r,
         result) = acre.build(config,
                              config_dir="%s/appengine-config" % site.site_dir,
                              war=True)

        if not r:
            return c.error("Acre failed to build, aborting.")

        if not c.options.nosite:
            status = acre.start(war=True)

            if not status:
                return c.error(
                    'Could not start new acre war bundle under appengine development server, aborting deployment'
                )

        c.log("\nDeployment Summary " + "*" * 45 + "\n", color=c.BLUE)
        c.log("  Config: %s" % config, color=c.BLUE)
        c.log("  Deployed URL: http://%s" % acre.site_host(True), color=c.BLUE)
        if app_version is None:
            c.log("  AppEngine URL: http://%s.appspot.com/" % app_id,
                  color=c.BLUE)
        else:
            c.log("  AppEngine URL: http://%s.%s.appspot.com/" %
                  (app_version, app_id),
                  color=c.BLUE)
        c.log(
            "  AppEngine Dashboard: https://appengine.google.com/dashboard?&app_id=%s\n"
            % app_id,
            color=c.BLUE)
        c.log("*" * 65 + "\n", color=c.BLUE)

        for directory in acre.site_dir(war=True):
            if os.path.isdir(directory + '/googlecode'):
                shutil.rmtree(directory + '/googlecode')

        if not c.options.nosite:
            apps = acre.fs_routed_apps()

            if not len(apps):
                raise FatalException(
                    "Something went wrong, there are no apps to bundle with Acre, aborting!"
                )

            for app in apps:
                result = app.copy_to_acre_dir(war=True)
                if not result:
                    c.error(
                        'Failed to copy %s to app-engine bundle, continuing with other apps...'
                        % app)

            # By default, push the environments app too unless --failover was specified.
            if not c.options.failover:
                acre.bundle_environments()

            c.log('The following apps were bundled:\n')
            for app in sorted(apps):
                c.log('\t%s' % app)

        acre.bundle_static_files()

        c.log('\nStarting deployment...', color=c.BLUE)
        if not acre.deploy(target=config):
            return c.error('Deployment failed.')

        if c.options.failover:
            c.log('\nStarting deployment of failover version...', color=c.BLUE)
            r = acre.prepare_failover()

            if not r:
                return c.error(
                    'Failed to prepare failover version of acre, aborting.')

            acre.bundle_environments()

            if not acre.deploy(config):
                return c.error('Failover deployment failed.')

        return True