def log_file_exists(self,filePath): if authentication.is_logged_in(cherrypy.session): try: with open(os.path.abspath(current_dir) + '\\\\' + filePath): return OkResponse("Ok") except IOError: raise cherrypy.HTTPError('404', 'File does not exist.') else: return ErrorResponse("You must login to see log files")
def index(self): if authentication.is_logged_in(cherrypy.session): user = authentication.get_current_user() if authentication.is_master(user): redirect(URL_MASTER) else: customers = assigneesHandler.get_customers(user.get('username')) #Normal users can only be assigned to one customer. if customers: customer = customers.pop() redirect(URL_USER + str(customer.get('customer'))) else: redirect(URL_LOGIN) else: redirect(URL_LOGIN)
def fetch_latest_mail(): if authentication.is_logged_in(): response, subject = mail.get_body_from_single_message() wd = prepare_events_for_calendar(subject, response) copied = copy.deepcopy(wd) copied.sort(key=lambda r: r.start_time) for workday in copied: locale.setlocale(locale.LC_ALL, 'nl_NL.utf8') workday.start_time = datetime.strftime( dateutil.parser.parse(workday.start_time), "%A %e %B, %Y, %H:%M") workday.end_time = datetime.strftime( dateutil.parser.parse(workday.end_time), "%A %e %B, %Y, %H:%M") locale.setlocale(locale.LC_ALL, 'C') return render_template('summary.html', events=copied, auth=True) else: return redirect(url_for('authentication.login'))
def download_log(self, filePath): if authentication.is_logged_in(cherrypy.session): return serve_file(os.path.abspath(current_dir) + '\\\\' + filePath, "application/x-download", "attachment") else: return ErrorResponse("You must login to download the log file")