示例#1
0
    def action_rollback(self, options, args):
        """launch 'appcfg.py rollback'
        """
        self.setup_stubs(options)
        from google.appengine.tools import appcfg

        appcfg.main(["", "rollback", "."])
示例#2
0
    def action_update(self, options, args):
        """launch 'appcfg.py update'
        """
        self.setup_stubs(options)
        from google.appengine.tools import appcfg

        appcfg.main(["appcfg.py", "update", "."])
    def run_from_argv(self, argv):
        parser = self.create_parser(argv[0], argv[1])
        options, args = parser.parse_args(argv[2:])
        handle_default_options(options)

        if not options.settings:# or not options.settings.endswith(settings.ENV_NAME):
            raise ImproperlyConfigured("Settings file has to be specified"
                " explicitly when deploying")

        stderr = getattr(options, 'stderr', sys.stderr)

        try:
            if len(args) > 0 and args[0] == 'update':
                self.update(argv[0:2]+args)
            elif len(args) > 0 and args[0] == 'prepare':
                self.prepare()
            elif len(args) > 0 and args[0] == 'updatebackends':
                self._update(argv[0:2]+['--backends', 'update']+args[1:])
            elif len(args) > 0 and args[0] == 'updatefast':
                self._update(argv[0:2]+['update']+args[1:])
            elif len(args) > 0 and args[0] == 'preparefast':
                self.clean_upload()
                self.prepare_upload()
            else:
                appcfg.main(argv[1:2] + args + [PROJECT_DIR])
        except Exception, e:
            if getattr(options, 'traceback', False):
                traceback.print_exc()
            else:
                stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e)))
            sys.exit(1)
示例#4
0
def run_appcfg(argv):
    # We don't really want to use that one though, it just executes this one
    from google.appengine.tools import appcfg

    # Reset the logging level to WARN as appcfg will spew tons of logs on INFO
    logging.getLogger().setLevel(logging.WARN)

    new_args = argv[:]
    new_args[1] = 'update'
    if appconfig.runtime != 'python':
        new_args.insert(1, '-R')
    new_args.append(PROJECT_DIR)
    syncdb = True
    if '--nosyncdb' in new_args:
        syncdb = False
        new_args.remove('--nosyncdb')
    appcfg.main(new_args)

    if syncdb:
        print 'Running syncdb.'
        # Wait a little bit for deployment to finish
        for countdown in range(9, 0, -1):
            sys.stdout.write('%s\r' % countdown)
            time.sleep(1)
        from django.db import connections
        for connection in connections.all():
            if hasattr(connection, 'setup_remote'):
                connection.setup_remote()
        call_command('syncdb', remote=True, interactive=True)

    if getattr(settings, 'ENABLE_PROFILER', False):
        print '--------------------------\n' \
              'WARNING: PROFILER ENABLED!\n' \
              '--------------------------'
示例#5
0
    def run_from_argv(self, argv):
        parser = self.create_parser(argv[0], argv[1])
        options, args = parser.parse_args(argv[2:])
        handle_default_options(options)

        if not options.settings:  # or not options.settings.endswith(settings.ENV_NAME):
            raise ImproperlyConfigured("Settings file has to be specified"
                                       " explicitly when deploying")

        stderr = getattr(options, 'stderr', sys.stderr)

        try:
            if len(args) > 0 and args[0] == 'update':
                self.update(argv[0:2] + args)
            elif len(args) > 0 and args[0] == 'prepare':
                self.prepare()
            elif len(args) > 0 and args[0] == 'updatebackends':
                self._update(argv[0:2] + ['--backends', 'update'] + args[1:])
            elif len(args) > 0 and args[0] == 'updatefast':
                self._update(argv[0:2] + ['update'] + args[1:])
            elif len(args) > 0 and args[0] == 'preparefast':
                self.clean_upload()
                self.prepare_upload()
            else:
                appcfg.main(argv[1:2] + args + [PROJECT_DIR])
        except Exception, e:
            if getattr(options, 'traceback', False):
                traceback.print_exc()
            else:
                stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e)))
            sys.exit(1)
示例#6
0
def run_file(file_path, globals_, script_dir=SCRIPT_DIR):
    """Execute the file at the specified path with the passed-in globals."""
    script_name = os.path.basename(file_path)

    if re.match(OAUTH_CLIENT_EXTRA_PATH_SCRIPTS, script_name):
        extra_extra_paths = OAUTH_CLIENT_EXTRA_PATHS
    # elif re.match(GOOGLE_SQL_EXTRA_PATH_SCRIPTS, script_name):
    #   extra_extra_paths = GOOGLE_SQL_EXTRA_PATHS
    # elif re.match(API_SERVER_EXTRA_PATH_SCRIPTS, script_name):
    #   extra_extra_paths = API_SERVER_EXTRA_PATHS
    # else:
    #   extra_extra_paths = []
    #fix_sys_path(extra_extra_paths)
    fix_sys_path()

    adjust_fancy_urllib()

    if 'google' in sys.modules:
        del sys.modules['google']

    #script_name = SCRIPT_EXCEPTIONS.get(script_name, script_name)
    # script_dir = SCRIPT_DIR_EXCEPTIONS.get(script_name, script_dir)
    #script_path = os.path.join(script_dir, script_name)
    #execfile(script_path, globals_)
    from google.appengine.tools import appcfg
    appcfg.main(sys.argv)
示例#7
0
def run_file(file_path, globals_, script_dir=SCRIPT_DIR):
  """Execute the file at the specified path with the passed-in globals."""
  script_name = os.path.basename(file_path)

  if re.match(OAUTH_CLIENT_EXTRA_PATH_SCRIPTS, script_name):
    extra_extra_paths = OAUTH_CLIENT_EXTRA_PATHS
  # elif re.match(GOOGLE_SQL_EXTRA_PATH_SCRIPTS, script_name):
  #   extra_extra_paths = GOOGLE_SQL_EXTRA_PATHS
  # elif re.match(API_SERVER_EXTRA_PATH_SCRIPTS, script_name):
  #   extra_extra_paths = API_SERVER_EXTRA_PATHS
  # else:
  #   extra_extra_paths = []
  #fix_sys_path(extra_extra_paths)
  fix_sys_path()

  adjust_fancy_urllib()



  if 'google' in sys.modules:
    del sys.modules['google']

  #script_name = SCRIPT_EXCEPTIONS.get(script_name, script_name)
  # script_dir = SCRIPT_DIR_EXCEPTIONS.get(script_name, script_dir)
  #script_path = os.path.join(script_dir, script_name)
  #execfile(script_path, globals_)
  from google.appengine.tools import appcfg
  appcfg.main(sys.argv)
示例#8
0
def run_appcfg(argv):
    # We don't really want to use that one though, it just executes this one
    from google.appengine.tools import appcfg

    # Reset the logging level to WARN as appcfg will spew tons of logs on INFO
    logging.getLogger().setLevel(logging.WARN)

    new_args = argv[:]
    new_args[1] = "update"
    new_args.append(PROJECT_DIR)
    syncdb = True
    if "--nosyncdb" in new_args:
        syncdb = False
        new_args.remove("--nosyncdb")
    appcfg.main(new_args)

    if syncdb:
        print "Running syncdb."
        # Wait a little bit for deployment to finish
        for countdown in range(9, 0, -1):
            sys.stdout.write("%s\r" % countdown)
            time.sleep(1)
        from django.db import connections

        for connection in connections.all():
            if hasattr(connection, "setup_remote"):
                connection.setup_remote()
        call_command("syncdb", remote=True, interactive=True)

    if getattr(settings, "ENABLE_PROFILER", False):
        print "--------------------------\n" "WARNING: PROFILER ENABLED!\n" "--------------------------"
示例#9
0
def run_appcfg(argv):
    # We don't really want to use that one though, it just executes this one
    from google.appengine.tools import appcfg

    # Reset the logging level to WARN as appcfg will spew tons of logs on INFO
    logging.getLogger().setLevel(logging.WARN)

    new_args = argv[:]
    new_args[1] = 'update'
    new_args.append(PROJECT_DIR)
    syncdb = True
    if '--nosyncdb' in new_args:
        syncdb = False
        new_args.remove('--nosyncdb')
    appcfg.main(new_args)

    if syncdb:
        print 'Running syncdb.'
        # Wait a little bit for deployment to finish
        for countdown in range(9, 0, -1):
            sys.stdout.write('%s\r' % countdown)
            time.sleep(1)
        from django.db import connections
        for connection in connections.all():
            if hasattr(connection, 'setup_remote'):
                connection.setup_remote()
        call_command('syncdb', remote=True, interactive=True)

    if getattr(settings, 'ENABLE_PROFILER', False):
        print '--------------------------\n' \
              'WARNING: PROFILER ENABLED!\n' \
              '--------------------------'
示例#10
0
def main(argv):
    if 'DJANGO_SETTINGS_MODULE' not in os.environ:
        try:
            import settings # Assumed to be in the same directory.
        except ImportError:
            import sys
            sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to set the DJANGO_SETTINGS_MODULE environment variable.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
            sys.exit(1)
    
    from google.appengine.tools import appcfg
    appcfg.main(argv)
示例#11
0
def upload(dirname, appid):
    assert isinstance(dirname, basestring) and isinstance(appid, basestring)
    filename = os.path.join(dirname, 'app.yaml')
    template_filename = os.path.join(dirname, 'app.template.yaml')
    assert os.path.isfile(template_filename), u'%s not exists!' % template_filename
    with open(template_filename, 'rb') as fp:
        yaml = fp.read()
    with open(filename, 'wb') as fp:
        fp.write(re.sub(r'application:\s*\S+', 'application: '+appid, yaml))
    appcfg.main(['appcfg', 'rollback', dirname])
    appcfg.main(['appcfg', 'update', dirname])
示例#12
0
def upload(dirname, appid):
    assert isinstance(dirname, basestring) and isinstance(appid, basestring)
    filename = os.path.join(dirname, 'app.yaml')
    assert os.path.isfile(filename), u'%s not exists!' % filename
    with open(filename, 'rb') as fp:
        yaml = fp.read()
    yaml = re.sub(r'application:\s*\S+', 'application: ' + appid, yaml)
    with open(filename, 'wb') as fp:
        fp.write(yaml)
    appcfg.main(['appcfg', 'rollback', dirname])
    appcfg.main(['appcfg', 'update', dirname])
示例#13
0
def upload(dirname):
    if os.name == 'nt':
        appcfg.main(['appcfg', 'rollback', dirname])
        pargs = [GOAPP, 'deploy', dirname]
        p = subprocess.Popen(pargs, stdout=subprocess.PIPE, shell=True)
        p.communicate()
    else:
        appcfg.main(
            ['appcfg', 'rollback', '--noauth_local_webserver', dirname])
        pargs = [GOAPP, 'deploy', '--noauth_local_webserver', dirname]
        p = subprocess.Popen(pargs, stdout=subprocess.PIPE, shell=True)
        p.communicate()
示例#14
0
    def _update(self, argv):
        try:
            get_callable(PRE_UPDATE_HOOK)()
        except (AttributeError, ImportError):
            pass

        appcfg.main(argv[1:] + [PROJECT_DIR])

        try:
            get_callable(POST_UPDATE_HOOK)()
        except (AttributeError, ImportError):
            pass
    def _update(self, argv):
        try:
            get_callable(PRE_UPDATE_HOOK)()
        except (AttributeError, ImportError):
            pass

        appcfg.main(argv[1:] + [PROJECT_DIR])

        try:
            get_callable(POST_UPDATE_HOOK)()
        except (AttributeError, ImportError):
            pass
示例#16
0
def upload(dirname, appid):
    assert isinstance(dirname, basestring) and isinstance(appid, basestring)
    filename = os.path.join(dirname, "app.yaml")
    template_filename = os.path.join(dirname, "app.yaml.template")
    assert os.path.isfile(template_filename), u"%s not exists!" % template_filename
    with open(template_filename, "rb") as fp:
        yaml = fp.read()
    with open(filename, "wb") as fp:
        fp.write(re.sub(r"application:\s*\S+", "application: " + appid, yaml))
    appcfg.main(["appcfg", "rollback", dirname])
    appcfg.main(["appcfg", "update", dirname])
    try:
        os.remove(appengine_rpc.HttpRpcServer.DEFAULT_COOKIE_FILE_PATH)
    except OSError:
        pass
示例#17
0
def upload(dirname, appid):
    assert isinstance(dirname, basestring) and isinstance(appid, basestring)
    filename = os.path.join(dirname, 'app.yaml')
    assert os.path.isfile(filename), u'%s not exists!' % filename
    with open(filename, 'rb') as fp:
        yaml = fp.read()
    with open(filename, 'wb') as fp:
        fp.write(re.sub(r'application:\s*\S+', 'application: '+appid, yaml))
    appcfg.main(['appcfg', 'rollback', dirname])
    appcfg.main(['appcfg', 'update', dirname])
    with open(filename, 'wb') as fp:
        fp.write(yaml)
    try:
        os.remove(appengine_rpc.HttpRpcServer.DEFAULT_COOKIE_FILE_PATH)
    except OSError:
        pass
示例#18
0
def main(argv):
    if "DJANGO_SETTINGS_MODULE" not in os.environ:
        try:
            import settings  # Assumed to be in the same directory.
        except ImportError:
            import sys

            sys.stderr.write(
                "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to set the DJANGO_SETTINGS_MODULE environment variable.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
                % __file__
            )
            sys.exit(1)

    from google.appengine.tools import appcfg

    appcfg.main(argv)
示例#19
0
def upload(dirname, appid):
    assert isinstance(dirname, basestring) and isinstance(appid, basestring)
    filename = os.path.join(dirname, 'app.yaml')
    assert os.path.isfile(filename), u'%s not exists!' % filename
    with open(filename, 'rb') as fp:
        yaml = fp.read()
    yaml=re.sub(r'application:\s*\S+', 'application: '+appid, yaml)
    with open(filename, 'wb') as fp:
        fp.write(yaml)
    if sys.modules.has_key('google'):
        del sys.modules['google']
    from google.appengine.tools import appengine_rpc
    from google.appengine.tools import appcfg
    appengine_rpc.HttpRpcServer.DEFAULT_COOKIE_FILE_PATH = './.appcfg_cookies'
    appcfg.main(['appcfg', 'rollback', dirname])
    appcfg.main(['appcfg', 'update', dirname])
示例#20
0
    def update(self, argv):
        self.clean_upload()

        try:
            self.prepare_upload()

            try:
                get_callable(PRE_UPDATE_HOOK)()
            except (AttributeError, ImportError):
                pass

            appcfg.main(argv[1:] + [PROJECT_DIR])

            try:
                get_callable(POST_UPDATE_HOOK)()
            except (AttributeError, ImportError):
                pass

        finally:
            self.clean_upload()
示例#21
0
    def update(self, argv):
        self.clean_upload()

        try:
            self.prepare_upload()

            try:
                get_callable(PRE_UPDATE_HOOK)()
            except (AttributeError, ImportError):
                pass

            appcfg.main(argv[1:] + [PROJECT_DIR])

            try:
                get_callable(POST_UPDATE_HOOK)()
            except (AttributeError, ImportError):
                pass

        finally:
            self.clean_upload()
示例#22
0
def run_appcfg(argv):
    # We don't really want to use that one though, it just executes
    # this one.
    from google.appengine.tools import appcfg

    # Reset the logging level to WARN as appcfg will spew tons of logs
    # on INFO.
    logging.getLogger().setLevel(logging.WARN)

    new_args = argv[:]
    new_args[1] = 'update'
    if appconfig.runtime != 'python':
        new_args.insert(1, '-R')
    new_args.append(PROJECT_DIR)
    syncdb = True
    if '--nosyncdb' in new_args:
        syncdb = False
        new_args.remove('--nosyncdb')
    appcfg.main(new_args)

    from ...db.stubs import stub_manager

    if syncdb:
        print "Running syncdb."
        # Wait a little bit for deployment to finish.
        for countdown in range(9, 0, -1):
            sys.stdout.write('%s\r' % countdown)
            time.sleep(1)
        from django.db import connections

        for connection in connections.all():
            #If we don't support joins, assume this is the datastore
            if not connection.features.supports_joins:
                stub_manager.setup_remote_stubs(connection)
        call_command('syncdb', remote=True, interactive=True)

    if getattr(settings, 'ENABLE_PROFILER', False):
        print "--------------------------\n" \
              "WARNING: PROFILER ENABLED!\n" \
              "--------------------------"
示例#23
0
def run_appcfg(argv):
    # We don't really want to use that one though, it just executes
    # this one.
    from google.appengine.tools import appcfg

    # Reset the logging level to WARN as appcfg will spew tons of logs
    # on INFO.
    logging.getLogger().setLevel(logging.WARN)

    new_args = argv[:]
    new_args[1] = 'update'
    if appconfig.runtime != 'python':
        new_args.insert(1, '-R')
    new_args.append(PROJECT_DIR)
    syncdb = True
    if '--nosyncdb' in new_args:
        syncdb = False
        new_args.remove('--nosyncdb')
    appcfg.main(new_args)

    from ...db.base import DatabaseWrapper
    from ...db.stubs import stub_manager

    if syncdb:
        print "Running syncdb."
        # Wait a little bit for deployment to finish.
        for countdown in range(9, 0, -1):
            sys.stdout.write('%s\r' % countdown)
            time.sleep(1)
        from django.db import connections

        for connection in connections.all():
            if isinstance(connection, DatabaseWrapper):
                stub_manager.setup_remote_stubs(connection)
        call_command('syncdb', remote=True, interactive=True)

    if getattr(settings, 'ENABLE_PROFILER', False):
        print "--------------------------\n" \
              "WARNING: PROFILER ENABLED!\n" \
              "--------------------------"
示例#24
0
        def finalize(self):
            pass
        def output_entities(self, entity_generator):
            pass
    return dummy()
Exporter.RegisteredExporter.func_code = DummyExporter.func_code

# 削除処理(BulkExporterThreadのTransferItemメソッドを横取りする)
def delete(self, item):
    retval = self.request_manager.GetEntities(item)
    # 取得してきたentitiesを全削除
    db.delete(retval.keys)
    retval.entities = []
    retval.keys = []
    return retval

BulkExporterThread.TransferItem.im_func.func_code = delete.func_code


if __name__ == '__main__':
    # 引数, オプションを追加
    sys.argv.insert(1, 'download_data')
    sys.argv.insert(2, '--filename=')
    sys.argv.insert(3, '--config_file=' + sys.argv[0])
    # 引数で指定したkind名でModelクラスを定義
    opts, unused_args =  getopt.getopt(sys.argv[2:], None, bulkloader.FLAG_SPEC)
    kind = [x[1] for x in opts if x[0] == '--kind'][0]
    exec "class %s(db.Model): pass" % kind

    appcfg.main(sys.argv)
示例#25
0
 def run_from_argv(self, argv):
     if len(argv) > 2 and argv[2] == 'update':
         self.update(argv)
     else:
         appcfg.main(argv[1:] + [PROJECT_DIR])
示例#26
0
 def run_from_argv(self, argv):
     if len(argv) > 2 and argv[2] == 'update':
         self.update(argv)
     else:
         appcfg.main(argv[1:] + [PROJECT_DIR])