def ajaxUpdate(self): # Make sure this is requested via ajax request_type = cherrypy.request.headers.get('X-Requested-With') if str(request_type).lower() == 'xmlhttprequest': pass else: status_msg = "This page exists, but is not accessible via web browser" return serve_template(templatename="index.html", title="404 - Page Not Found", msg=status_msg) return serve_template(templatename="ajaxUpdate.html")
def update(self): cherrystrap.SIGNAL = 'update' message = 'updating ...' return serve_template(templatename="shutdown.html", title="Update", message=message, timer=30)
def restart(self): cherrystrap.SIGNAL = 'restart' message = 'restarting ...' return serve_template(templatename="shutdown.html", title="Restart", message=message, timer=15)
def operations(self, script=None, issue_list_input=None): status, msg = '', '' if jiraappy.JIRA_LOGIN_STATUS: consumer, client = backend.stored_oauth() if request.method == 'POST': script = request.params['script'] issue_list_input = request.params['issue_list_input'] issue_list = [x.strip() for x in issue_list_input.split(',')] if script == 'bulk-delete-worklogs' and issue_list_input: status, msg = jiraInt.bulkDeleteWorklogs(issue_list) else: status, msg = backend.ajaxMSG( 'failure', 'No issues entered for processing') else: pass else: status, msg = backend.ajaxMSG( 'failure', 'Can not operate on JIRA without being logged in') return serve_template(templatename="operations.html", title="Bulk Operations", status=status, msg=msg)
def caller(self, call=None, action=None): status, msg = '', '' if call == 'reindex': status, msg = jiraInt.reindex(action) return serve_template(templatename="caller.html", title="Call JIRA", status=status, msg=msg)
def oauth_request(self): authorize_token_url, status, msg = backend.redirect_oauth() if not authorize_token_url: return serve_template(templatename="index.html", title="Home", status=status, msg=msg) else: raise cherrypy.HTTPRedirect(authorize_token_url)
def shutdown(self): cherrystrap.config_write() cherrystrap.SIGNAL = 'shutdown' message = 'shutting down ...' return serve_template(templatename="shutdown.html", title="Exit", message=message, timer=15) return page
def index(self): subroutine = subroutines() staticData = subroutine.static_subroutine() numCPUs = len(subroutine.cpuload_subroutine()) numDisks = len(subroutine.diskio_subroutine()) numPartitions = len(subroutine.partitions_subroutine()) fansTemps = subroutine.sysfiles_subroutine() return serve_template(templatename="index.html", title="Home", staticData=staticData, numCPUs=numCPUs, numDisks=numDisks, numPartitions=numPartitions, fansTemps=fansTemps)
def config(self): http_look_dir = os.path.join(cherrystrap.PROG_DIR, 'static/interfaces/') http_look_list = [ name for name in os.listdir(http_look_dir) if os.path.isdir(os.path.join(http_look_dir, name)) ] config = { "http_look_list": http_look_list } return serve_template(templatename="config.html", title="Settings", config=config)
def downloadLog(self, logFile=None): message = {} if logFile: try: return serve_file(logFile, "application/x-download", "attachment") except Exception, e: message['status'] = 'danger' message['message'] = 'There was a problem downloading log file %s' % logFile logger.error('There was a problem downloading log file %s: %s' % (logFile, e)) return serve_template(templatename="logs.html", title="Logs", message=message)
def index(self, oauth_token=None): if oauth_token: status, msg = backend.validate_oauth(oauth_token) else: status, msg = '', '' return serve_template(templatename="index.html", title="Home", status=status, msg=msg)
def oauth_logout(self): jiraappy.JIRA_OAUTH_TOKEN = None jiraappy.JIRA_OAUTH_SECRET = None cherrystrap.config_write() jiraappy.JIRA_LOGIN_STATUS = None jiraappy.JIRA_LOGIN_USER = None status, msg = backend.ajaxMSG('success', 'Successfully logged out of JIRA OAuth') return serve_template(templatename="index.html", title="Home", status=status, msg=msg)
def checkGithub(self): # Make sure this is requested via ajax request_type = cherrypy.request.headers.get('X-Requested-With') if str(request_type).lower() == 'xmlhttprequest': pass else: status_msg = "This page exists, but is not accessible via web browser" return serve_template(templatename="index.html", title="404 - Page Not Found", msg=status_msg) from cherrystrap import versioncheck versioncheck.checkGithub() cherrystrap.IGNORE_UPDATES = False
def config(self): http_look_dir = os.path.join(cherrystrap.PROG_DIR, 'static/interfaces/') http_look_list = [ name for name in os.listdir(http_look_dir) if os.path.isdir(os.path.join(http_look_dir, name)) ] config = {"http_look_list": http_look_list} return serve_template(templatename="config.html", title="Settings", config=config)
def processes(self): return serve_template(templatename="processes.html", title="Processes")
def configlogs(self): return serve_template(templatename="configlogs.html", title="Configure Logs")
def log(self): return serve_template(templatename="log.html", title="Log", lineList=cherrystrap.LOGLIST)
def logs(self): return serve_template(templatename="logs.html", title="Logs")
def logs(self): return serve_template(templatename="logs.html", title="Log", lineList=cherrystrap.LOGLIST)
def template(self): return serve_template(templatename="template.html", title="Template Reference")
def error_page_404(status, message, traceback, version): status_msg = "%s - %s" % (status, message) return serve_template(templatename="index.html", title="404 - Page Not Found", msg=status_msg)
def downloadLog(self, logFile=None): message = {} if logFile: try: return serve_file(logFile, "application/x-download", "attachment") except Exception, e: message['status'] = 'danger' message['message'] = 'There was a problem downloading log file %s' % logFile logger.error('There was a problem downloading log file %s: %s' % (logFile, e)) return serve_template(templatename="logs.html", title="Logs", message=message) else: message['status'] = 'warning' message['message'] = 'You must define a logFile to download' return serve_template(templatename="logs.html", title="Logs", message=message) downloadLog.exposed = True @require() def shutdown(self): cherrystrap.config_write() cherrystrap.SIGNAL = 'shutdown' message = 'shutting down ...' return serve_template(templatename="shutdown.html", title="Exit", message=message, timer=10) return page shutdown.exposed = True @require() def restart(self): cherrystrap.SIGNAL = 'restart'
def listener(self): return serve_template(templatename="listener.html", title="Webhooks")
def configrules(self): return serve_template(templatename="configrules.html", title="Configure Rules")
def index(self): return serve_template(templatename="index.html", title="Home")
def get_loginform(self, username, msg="Login Required", source="/"): return serve_template(templatename="login.html", title="Login", username=username, msg=msg, source=source)