Example #1
0
 def handle(self, website=None, sourcedir='static', **options):
     if not options['noinput'] and ask_boolean("Are you sure? This will override all files remotely!", default=True) == 'false':
         return
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     if not website:
         raise CommandError("You must provide the name of the website from which you want to push the static files as first argument")
     if not os.path.exists(sourcedir):
         raise CommandError("Source directory %r not found" % sourcedir)
     url = self.get_absolute_url('/api/v1/io/static/push/')
     username, password = self.get_auth(options['noinput'])
     session = requests.session()
     login_url = self.get_absolute_url(LOGIN_PATH)
     response = session.post(login_url, {'username': username, 'password': password})
     if response.status_code != 204:
         printer.error("Login failed")
         return
     data = {'name': website}
     files = {'static': self.build_tarball(sourcedir, printer)}
     response = session.post(url, data=data, files=files)
     if response.status_code == 204:
         printer.always("Sucess")
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Push failed: Bad request")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Push failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Push failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Push failed, check djeese.log for more details")
 def handle(self, website=None, outputdir='static', **options):
     if not options['noinput'] and ask_boolean("Are you sure? This will override all files in %s!" % outputdir, default=True) == 'false':
         return
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     if not website:
         raise CommandError("You must provide the name of the website from which you want to clone the static files as first argument")
     url = self.get_absolute_url('/api/v1/io/static/clone/')
     username, password = self.get_auth(options['noinput'])
     session = requests.session()
     login_url = self.get_absolute_url(LOGIN_PATH)
     response = session.post(login_url, {'username': username, 'password': password})
     if response.status_code != 204:
         printer.error("Login failed")
         return
     data = {'name': website}
     response = session.get(url, params=data)
     if response.status_code == 200:
         self.finish_clone(response, outputdir, printer)
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Clone failed: Bad request")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Clone failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Clone failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Clone failed, check djeese.log for more details")
Example #3
0
 def handle(self, website=None, outputdir='static', **options):
     if not options['noinput'] and ask_boolean("Are you sure? This will override all files in %s!" % outputdir, default=True) == 'false':
         return
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     if not website:
         raise CommandError("You must provide the name of the website from which you want to clone the static files as first argument")
     url = self.get_absolute_url('/api/v1/io/static/clone/')
     session = self.login(printer, options['noinput'])
     if not session:
         return
     data = {'name': website}
     response = session.get(url, params=data)
     if response.status_code == 200:
         stage = tempfile.mkdtemp()
         try:
             self.finish_clone(response, outputdir, stage, printer)
         finally:
             shutil.rmtree(stage, ignore_errors=True)
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Clone failed: Bad request")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Clone failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Clone failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Clone failed, check djeese.log for more details")
 def handle(self, **options):
     config = AppConfiguration(1)
     letterfirst = RegexValidator(r'^[a-zA-Z]', "Must start with a letter")
     name = contrib(config, 'app', 'name', ask, "Name", letterfirst)
     packagename = contrib(config, 'app', 'packagename', ask, 'Package name on PyPI', SlugValidator(), default=slugify(name))
     check_net = ask_boolean("Should we try to get additional information from djangopackages?", default=True)
     if check_net:
         data = get_package_data(packagename)
     else:
         data = defaultdict(lambda:None)
     modules = [p for p in os.listdir('.') if os.path.exists(os.path.join(p, '__init__.py'))]
     contrib(config, 'app', 'private', ask_boolean, "Private", default=False)
     contrib(config, 'app', 'url', ask, 'URL', default=data['url'])
     contrib(config, 'app', 'author', ask, 'Author', default=data['author'], required=False)
     contrib(config, 'app', 'author-url', ask, 'Author URL (optional)', default=data['author_url'], required=False)
     contrib(config, 'app', 'installed-apps', ask_multi, "Installed apps", minitems=1)
     contrib(config, 'app', 'version', ask, 'Version', default=data['version'])
     contrib(config, 'app', 'description', ask, 'Description (short)', default=data['description'])
     contrib(config, 'app', 'license', ask, 'License', default=data['license'])
     contrib(config, 'app', 'license-path', ask, 'Path to license file', PathValidator(), default=guess_license_path())
     contrib(config, 'app', 'translation-url', ask, 'URL to the translation page, eg transifex (optional)', URLValidator(), required=False)
     contrib(config, 'app', 'settings', ask_multi, 'Settings (optional)')
     contrib(config, 'app', 'plugins', ask_multi, 'Plugin (class) names (optional)')
     contrib(config, 'app', 'apphook', ask_multi, 'Apphook (class) names (optional)')
     for setting in config['app'].getlist('settings'):
         contrib(config, setting, 'name', ask, 'Name of the setting %r (Python)' % setting)
         contrib(config, setting, 'verbose-name', ask, 'Verbose name of the setting %r' % setting)
         contrib(config, setting, 'type', ask_choice, 'Type of the setting %r' % setting, choices=VALID_TYPES)
         contrib(config, setting, 'default', ask, 'Default value for setting %r (optional)' % setting, required=False)
         contrib(config, setting, 'required', ask_boolean, 'Is setting %r required' % setting, default=True)
         if config[setting].get('default', None):
             contrib(config, setting, 'editable', ask_boolean, 'Is setting %r editable' % setting, default=True)
     if ask_boolean("Does your application expose templates?", default=True) == 'true':
         while True:
             name = ask('Template path (eg %s/plugin.html)' % config['app']['packagename'])
             path = ask('Path to the source of the template', PathValidator(), default=guess_path(name, modules))
             config['templates'][name] = path
             if ask_boolean("Are there more templates?") == 'false':
                 break
     fname = '%s.ini' % packagename
     config.write(fname)
Example #5
0
    def handle(self, **options):
        config = BoilerplateConfiguration(1)
        contrib(config, 'boilerplate', 'name', ask, "Name", letterfirst)
        contrib(config, 'boilerplate', 'url', ask, 'Project URL (optional)', required=False)
        contrib(config, 'boilerplate', 'author', ask, 'Author')
        contrib(config, 'boilerplate', 'author-url', ask, 'Author URL (optional)', required=False)
        contrib(config, 'boilerplate', 'version', ask, 'Version')
        contrib(config, 'boilerplate', 'description', ask, 'Description (short)')
        contrib(config, 'boilerplate', 'license', ask, 'License')
        contrib(config, 'boilerplate', 'license-path', ask, 'Path to license file', PathValidator(), default=guess_license_path())
        print "Configuring CMS templates. Only list templates that should be selectable in the CMS"
        while True:
            name = ask('Verbose template name')
            path = ask('Path to the source of the template', PathValidator('templates'))
            config['templates'][path] = name
            if ask_boolean("Are there more templates?") == 'false':
                break

        config.write('boilerplate.ini')
 def get_auth(self, noinput=False):
     username, password = None, None
     if os.path.exists(AUTH_FILE):
         fobj = open(AUTH_FILE)
         try:
             data = fobj.read()
         finally:
             fobj.close()
         if data.count(':') == 1:
             username, password = [bit.strip() for bit in data.split(':')]
     if not (username and password):
         username = ask("Username")
         password = ask_password("Password:"******"Save login data?", default=True) == 'true':
             fobj = open(AUTH_FILE, 'w')
             try:
                 data = fobj.write(u'%s:%s' % (username, password))
             finally:
                 fobj.close()
     return username, password
Example #7
0
 def get_auth(self, noinput=False):
     email, password = None, None
     if os.path.exists(AUTH_FILE):
         fobj = open(AUTH_FILE)
         try:
             data = fobj.read()
         finally:
             fobj.close()
         if data.count(':') == 1:
             email, password = [bit.strip() for bit in data.split(':')]
     if not (email and password):
         email = ask("E-Mail")
         password = ask_password("Password:"******"Save login data?",
                                   default=True) == 'true':
             fobj = open(AUTH_FILE, 'w')
             try:
                 data = fobj.write(u'%s:%s' % (email, password))
             finally:
                 fobj.close()
     return email, password
    def handle(self, **options):
        config = BoilerplateConfiguration(1)
        contrib(config, 'boilerplate', 'name', ask, "Name", letterfirst)
        contrib(config,
                'boilerplate',
                'url',
                ask,
                'Project URL (optional)',
                required=False)
        contrib(config, 'boilerplate', 'author', ask, 'Author')
        contrib(config,
                'boilerplate',
                'author-url',
                ask,
                'Author URL (optional)',
                required=False)
        contrib(config, 'boilerplate', 'version', ask, 'Version')
        contrib(config, 'boilerplate', 'description', ask,
                'Description (short)')
        contrib(config, 'boilerplate', 'license', ask, 'License')
        contrib(config,
                'boilerplate',
                'license-path',
                ask,
                'Path to license file',
                PathValidator(),
                default=guess_license_path())
        print "Configuring CMS templates. Only list templates that should be selectable in the CMS"
        while True:
            name = ask('Verbose template name')
            path = ask('Path to the source of the template',
                       PathValidator('templates'))
            config['templates'][path] = name
            if ask_boolean("Are there more templates?") == 'false':
                break

        config.write('boilerplate.ini')
Example #9
0
 def handle(self, website=None, outputdir='static', **options):
     if not options['noinput'] and ask_boolean(
             "Are you sure? This will override all files in %s!" %
             outputdir,
             default=True) == 'false':
         return
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     if not website:
         raise CommandError(
             "You must provide the name of the website from which you want to clone the static files as first argument"
         )
     url = self.get_absolute_url('/api/v1/io/static/clone/')
     session = self.login(printer, options['noinput'])
     if not session:
         return
     data = {'name': website}
     response = session.get(url, params=data)
     if response.status_code == 200:
         stage = tempfile.mkdtemp()
         try:
             self.finish_clone(response, outputdir, stage, printer)
         finally:
             shutil.rmtree(stage, ignore_errors=True)
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Clone failed: Bad request")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Clone failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Clone failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Clone failed, check djeese.log for more details")
Example #10
0
 def handle(self, **options):
     config = AppConfiguration(1)
     name = contrib(config, 'app', 'name', ask, "Name", letterfirst)
     packagename = contrib(config,
                           'app',
                           'packagename',
                           ask,
                           'Package name on PyPI',
                           SlugValidator(),
                           default=slugify(name))
     check_net = ask_boolean(
         "Should we try to get additional information from djangopackages?",
         default=True)
     if check_net:
         data = get_package_data(packagename)
     else:
         data = defaultdict(lambda: None)
     modules = [
         p for p in os.listdir('.')
         if os.path.exists(os.path.join(p, '__init__.py'))
     ]
     contrib(config,
             'app',
             'private',
             ask_boolean,
             "Private",
             default=False)
     contrib(config, 'app', 'url', ask, 'URL', default=data['url'])
     contrib(config,
             'app',
             'author',
             ask,
             'Author',
             default=data['author'],
             required=False)
     contrib(config,
             'app',
             'author-url',
             ask,
             'Author URL (optional)',
             default=data['author_url'],
             required=False)
     contrib(config,
             'app',
             'installed-apps',
             ask_multi,
             "Installed apps",
             minitems=1)
     contrib(config,
             'app',
             'version',
             ask,
             'Version',
             default=data['version'])
     contrib(config,
             'app',
             'description',
             ask,
             'Description (short)',
             default=data['description'])
     contrib(config,
             'app',
             'license',
             ask,
             'License',
             default=data['license'])
     contrib(config,
             'app',
             'license-path',
             ask,
             'Path to license file',
             PathValidator(),
             default=guess_license_path())
     contrib(config,
             'app',
             'translation-url',
             ask,
             'URL to the translation page, eg transifex (optional)',
             URLValidator(),
             required=False)
     contrib(config, 'app', 'settings', ask_multi, 'Settings (optional)')
     contrib(config, 'app', 'plugins', ask_multi,
             'Plugin (class) names (optional)')
     contrib(config, 'app', 'apphook', ask_multi,
             'Apphook (class) names (optional)')
     for setting in config['app'].getlist('settings'):
         contrib(config, setting, 'name', ask,
                 'Name of the setting %r (Python)' % setting)
         contrib(config, setting, 'verbose-name', ask,
                 'Verbose name of the setting %r' % setting)
         contrib(config,
                 setting,
                 'type',
                 ask_choice,
                 'Type of the setting %r' % setting,
                 choices=VALID_TYPES)
         contrib(config,
                 setting,
                 'default',
                 ask,
                 'Default value for setting %r (optional)' % setting,
                 required=False)
         contrib(config,
                 setting,
                 'required',
                 ask_boolean,
                 'Is setting %r required' % setting,
                 default=True)
         if config[setting].get('default', None):
             contrib(config,
                     setting,
                     'editable',
                     ask_boolean,
                     'Is setting %r editable' % setting,
                     default=True)
     if ask_boolean("Does your application expose templates?",
                    default=True) == 'true':
         while True:
             name = ask('Template path (eg %s/plugin.html)' %
                        config['app']['packagename'])
             path = ask('Path to the source of the template',
                        PathValidator(),
                        default=guess_path(name, modules))
             config['templates'][name] = path
             if ask_boolean("Are there more templates?") == 'false':
                 break
     fname = '%s.ini' % packagename
     config.write(fname)