示例#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")
示例#2
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")
示例#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/')
     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")
 def handle(self, url=None, staticfolder='static', **options):
     if not url:
         raise CommandError("You must provide the url to your website file as first argument")
     if not os.path.exists(staticfolder):
         raise CommandError("Static folder %r not found." % staticfolder)
     server_address = ('', int(options['port']))
     printer = Printer(int(options['verbosity']))
     print "Open http://localhost:%s in your browser" % options['port']
     print "Use ctrl+c to stop the server"
     httpd = StaticServer(server_address, StaticHandler, url, staticfolder, printer)
     try:
         httpd.serve_forever()
     except KeyboardInterrupt:
         printer.always("Server shut down")
示例#5
0
 def handle(self, url=None, staticfolder='static', **options):
     if not url:
         raise CommandError(
             "You must provide the url to your website file as first argument"
         )
     if not os.path.exists(staticfolder):
         raise CommandError("Static folder %r not found." % staticfolder)
     server_address = ('', int(options['port']))
     printer = Printer(int(options['verbosity']))
     print "Open http://localhost:%s in your browser" % options['port']
     print "Use ctrl+c to stop the server"
     httpd = StaticServer(server_address, StaticHandler, url, staticfolder,
                          printer)
     try:
         httpd.serve_forever()
     except KeyboardInterrupt:
         printer.always("Server shut down")
示例#6
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 run(self, setupfile, appfile, username, password, **options):
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     config = AppConfiguration(printer=printer)
     config.read(appfile)
     bundle = bundle_app(setupfile, config) 
     appname = config['app']['name']
     response = self.upload(appname, bundle, username, password)
     if response.status_code == 201:
         printer.always("Upload successful (created)")
     elif response.status_code == 204:
         printer.always("Upload successful (updated)")
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Upload failed")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Upload failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Upload failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Upload failed, check djeese.log for more details")
 def run(self, boilerplatefile, session, printer, **options):
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     config = BoilerplateConfiguration(printer=printer)
     config.read(boilerplatefile)
     bundle = bundle_boilerplate(config) 
     boilerplatename = config['boilerplate']['name']
     response = self.upload(boilerplatename, bundle, session, printer)
     if response.status_code == 201:
         printer.always("Upload successful (created)")
     elif response.status_code == 204:
         printer.always("Upload successful (updated)")
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Upload failed")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Upload failed")
         self.clear_auth()
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Upload failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Upload failed, check djeese.log for more details")
示例#9
0
 def run(self, setupfile, appfile, username, password, **options):
     printer = Printer(int(options['verbosity']), logfile='djeese.log')
     config = AppConfiguration(printer=printer)
     config.read(appfile)
     bundle = bundle_app(setupfile, config)
     appname = config['app']['name']
     response = self.upload(appname, bundle, username, password)
     if response.status_code == 201:
         printer.always("Upload successful (created)")
     elif response.status_code == 204:
         printer.always("Upload successful (updated)")
     elif response.status_code == 400:
         self.handle_bad_request(response, printer)
         printer.always("Upload failed")
     elif response.status_code == 403:
         printer.error("Authentication failed")
         printer.always("Upload failed")
     elif response.status_code == 502:
         printer.error("Temporarily unavailable")
         printer.always("Upload failed")
     else:
         printer.error("Unexpected response: %s" % response.status_code)
         printer.log_only(response.content)
         printer.always("Upload failed, check djeese.log for more details")