Python config.log_file() Examples
The following are 12
code examples of config.log_file().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
config
, or try the search function
.
Example #1
Source File: file_managernano.py From homesecurity with MIT License | 6 votes |
def run(self): while len(self.files_not_sent)>0: try: if self._connected(): for f,now in self.files_not_sent: try: text="Motion detected in your room at {}. Please see attached video.\n".format(now) sem.send_mail(files=[mp4_folder+f],text=text) self.files_not_sent.remove((f,now)) except: continue if len(self.files_not_sent)>0: with open(log_dir+log_file,'a') as f: f.write(time.strftime("%a, %d %b %Y %H:%M:%S\n",time.localtime())) f.write(str(self.files_not_sent)) f.write('\n') except: continue
Example #2
Source File: file_manager.py From homesecurity with MIT License | 6 votes |
def run(self): while len(self.files_not_sent)>0: try: if self._connected(): for f,now in self.files_not_sent: try: text="Motion detected in your room at {}. Please see attached video.\n".format(now) sem.send_mail(files=[mp4_folder+f],text=text) self.files_not_sent.remove((f,now)) except: continue if len(self.files_not_sent)>0: with open(log_dir+log_file,'a') as f: f.write(time.strftime("%a, %d %b %Y %H:%M:%S\n",time.localtime())) f.write(str(self.files_not_sent)) f.write('\n') except: continue
Example #3
Source File: utils.py From simcoin with MIT License | 6 votes |
def config_logger(verbose): log_formatter = logging.Formatter("%(asctime)s.%(msecs)03d000 [%(processName)s-%(threadName)-12.12s] " "[%(levelname)-5.5s] %(message)s", "%Y-%m-%d %H:%M:%S") logging.Formatter.converter = time.gmtime root_logger = logging.getLogger() file_handler = logging.FileHandler(config.log_file, mode='w') file_handler.setFormatter(log_formatter) root_logger.addHandler(file_handler) console_handler = logging.StreamHandler(sys.stdout) console_handler.setFormatter(log_formatter) root_logger.addHandler(console_handler) if verbose: root_logger.setLevel(logging.DEBUG) else: root_logger.setLevel(logging.INFO)
Example #4
Source File: bugdialog.py From wxGlade with MIT License | 6 votes |
def _fill_dialog(self, exc_msg, exc_type, header): """Fill the bug dialog exc_msg: Short exception summary exc_type: Exception type as string header: Initial message see: SetContent(), SetContentEI()""" details = log.getBufferAsString() if not exc_msg: exc_msg = _('No summary available') summary = self.st_summary.GetLabel() % { 'exc_type':exc_type, 'exc_msg':exc_msg } self.st_header.SetLabel(header) self.st_summary.SetLabel(summary) self.tc_details.SetValue(details) howto = self.tc_howto_report.GetValue() howto = howto % {'log_file': config.log_file} self.tc_howto_report.SetValue(howto)
Example #5
Source File: run.py From httpninja with Apache License 2.0 | 5 votes |
def logThis(message,type='log'): if type=='log': message = u"{delim}{time}{delim} {message}".format(delim="~"*30, time=datetime.now(),message=unicode(message, errors='ignore')) log_file = config.log_file print message else: log_file = config.result_file with codecs.open(log_file, "a","utf-8") as myfile: myfile.write(message+'\n')
Example #6
Source File: file_managernano.py From homesecurity with MIT License | 5 votes |
def get_file_names(self): with open(log_dir+log_file,'r') as f: alltext=f.read().split('\n') for line in reversed(alltext): if len(line)>2 and '[' in line: #making sure there is some content files=eval(line) break else: files=[] return files
Example #7
Source File: postprocessing.py From simcoin with MIT License | 5 votes |
def execute(self): self._pool = Pool(config.pool_processors) self._thread_pool = ThreadPool(5) cli_stats = CliStats(self._context, self._writer) cli_stats.execute() self.clean_up_docker() logging.info(config.log_line_run_end + self._context.run_name) _flush_log_handlers() _extract_from_file(config.log_file, config.run_log, config.log_line_run_start + self._context.run_name, config.log_line_run_end + self._context.run_name) parser = Parser(self._context, self._writer) parser.execute() _collect_general_information() self._context.step_times.append(StepTimes(time.time(), 'postprocessing_end')) self._writer.write_csv(config.step_times_csv_file_name, StepTimes.csv_header, self._context.step_times) _create_report() self._pool.close() self._thread_pool.close() logging.info('Executed post processing')
Example #8
Source File: main.py From wxGlade with MIT License | 5 votes |
def on_autosave_timer(self, event): res = common.autosave_current() if res == 2: self.user_message(_("Auto saving... done")) elif not res: self.autosave_timer.Stop() config.preferences.autosave = False logging.info(_('Disable autosave function permanently')) wx.MessageBox( _('The autosave function failed. It has been disabled\n' 'permanently due to this error. Use the preferences\n' 'dialog to re-enable this functionality.\n' 'The details have been written to the wxGlade log file\n\n' 'The log file is: %s' % config.log_file ), _('Autosave Failed'), wx.OK | wx.CENTRE | wx.ICON_ERROR )
Example #9
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def init_stage1(options): """Initialise paths for wxGlade (first stage) Initialisation is split because the test suite doesn't work with proper initialised paths.""" config.version = config.get_version() common.init_paths(options) # initialise own logging extensions log.init(filename=config.log_file, encoding='utf-8', level='INFO') atexit.register(log.deinit) # print versions logging.info( _('Starting wxGlade version "%s" on Python %s'), config.version, config.py_version ) # print used paths logging.info(_('Base directory: %s'), config.wxglade_path) logging.info(_('Documentation directory: %s'), config.docs_path) logging.info(_('Icons directory: %s'), config.icons_path) logging.info(_('Build-in widgets directory: %s'), config.widgets_path) logging.info(_('Template directory: %s'), config.templates_path) logging.info(_('Credits file: %s'), config.credits_file) logging.info(_('License file: %s'), config.license_file) logging.info(_('Manual file: %s'), config.manual_file) logging.info(_('Tutorial file: %s'), config.tutorial_file) logging.info(_('Home directory: %s'), config.home_path) logging.info(_('Application data directory: %s'), config.appdata_path) logging.info(_('Configuration file: %s'), config.rc_file) logging.info(_('History file: %s'), config.history_file) logging.info(_('Log file: %s'), config.log_file) # adapt application search path sys.path.insert(0, config.wxglade_path) sys.path.insert(1, config.widgets_path)
Example #10
Source File: common.py From wxGlade with MIT License | 5 votes |
def _set_file_paths(options): "Set the full path for all files (config.*_file except default_output_file)" install_method = _get_install_method() if install_method == 'single_directory': config.credits_file = os.path.join(config.wxglade_path, 'CREDITS.txt') config.license_file = os.path.join(config.wxglade_path, 'LICENSE.txt') config.manual_file = os.path.join(config.docs_path, 'html', 'index.html') config.bmp_manual_file = os.path.join(config.docs_path, 'html', 'bitmaps.html') #config.tutorial_file = os.path.join(config.docs_path, 'Tutorial.html') else: config.credits_file = os.path.join(config.docs_path, 'CREDITS.txt') config.license_file = os.path.join(config.docs_path, 'LICENSE.txt') config.manual_file = os.path.join(config.docs_path, 'html', 'index.html') config.bmp_manual_file = os.path.join(config.docs_path, 'html', 'bitmaps.html') #config.tutorial_file = os.path.join(config.docs_path, 'html', 'tutorial.html') if not os.path.exists(config.credits_file): logging.error(_('Credits file "CREDITS.txt" not found!')) config.credits_file = '' if not os.path.exists(config.license_file): logging.error(_('License file "LICENSE.txt" not found!')) config.license_file = '' config.widgets_path = os.path.join(config.wxglade_path, 'widgets') # complete path to rc file if options and options.rc_file: if not os.path.exists(options.rc_file): logging.error(_('Specified config file does not exist')) config.rc_file = options.rc_file elif os.name == 'nt': config.rc_file = os.path.join(config.appdata_path, 'wxglade.ini') else: config.rc_file = os.path.join(config.appdata_path, 'wxgladerc') config.history_file = os.path.join(config.appdata_path, 'file_history.txt') config.log_file = os.path.join(config.appdata_path, 'wxglade.log')
Example #11
Source File: file_managernano.py From homesecurity with MIT License | 4 votes |
def run(self): # As long as we weren't asked to stop, try to take new tasks from the # queue. The tasks are taken with a blocking 'get', so no CPU # cycles are wasted while waiting. # Also, 'get' is given a timeout, so stoprequest is always checked, # even if there's nothing in the queue. while not self.stoprequest.isSet(): try: h264_filename = self.h264_q.get(True, 0.05) fname=mp4_folder+h264_filename now=time.strftime("%a, %d %b %Y %H:%M:%S",time.localtime()) #os.system("rm {}".format(fname)) os.system("mv {} {}".format(h264_folder+h264_filename,fname)) try: should_send,message=hd.determine_if_person_in(fname,is_nano=True) #if not should_send: if should_send: jpeg_name=fname[:fname.rfind('.')+1]+'jpg' if os.path.exists(jpeg_name): send_list=[fname,jpeg_name] else: send_list=[fname] sem.send_mail(files=send_list,text=message) self.files_sent.append((fname,now)) os.remove(fname) except Exception as e: print(str(e)) #if should_send: self.files_not_sent.append((fname,now)) except queue.Empty: #if nothing to do, we try to push files not sent earlier if self._connected() and len(self.files_not_sent)>0: for f,now in self.files_not_sent: try: text="Motion detected in your room at {}. Please see attached video.\n".format(now) sem.send_mail(files=[mp4_folder+f],text=text) self.files_not_sent.remove((f,now)) os.remove(mp4_folder+f) except: continue if time.time()-self.time_last_written>logwrite_th: self.time_last_written=time.time() if len(self.files_not_sent)>0: if self.files_not_sent != self.last_files_not_sent: self.last_files_not_sent=deepcopy(self.files_not_sent) with open(log_dir+log_file,'a') as f: f.write(time.strftime("%a, %d %b %Y %H:%M:%S\n",time.localtime())) f.write(str(self.files_not_sent)) f.write('\n') f.write('\n')
Example #12
Source File: file_manager.py From homesecurity with MIT License | 4 votes |
def run(self): # As long as we weren't asked to stop, try to take new tasks from the # queue. The tasks are taken with a blocking 'get', so no CPU # cycles are wasted while waiting. # Also, 'get' is given a timeout, so stoprequest is always checked, # even if there's nothing in the queue. while not self.stoprequest.isSet(): try: h264_filename = self.h264_q.get(True, 0.05) fname=mp4_folder+h264_filename[:h264_filename.rfind('.')]+'.mp4' now=time.strftime("%a, %d %b %Y %H:%M:%S",time.localtime()) os.system("rm {}".format(fname)) os.system("MP4Box -add {} {}".format(h264_folder+h264_filename,fname)) #os.system("python -u send_email.py {}".format(fname)) os.remove(h264_folder+h264_filename) try: should_send,message=hd.determine_if_person_in(fname) #if not should_send: if should_send: jpeg_name=fname[:fname.rfind('.')+1]+'jpg' if os.path.exists(jpeg_name): send_list=[fname,jpeg_name] else: send_list=[fname] sem.send_mail(files=send_list,text=message) self.files_sent.append((fname,now)) os.remove(fname) except Exception as e: print(str(e)) #if should_send: self.files_not_sent.append((fname,now)) # else: # self.files_not_sent.append(fname) except queue.Empty: #if nothing to do, we try to push files not sent earlier if self._connected() and len(self.files_not_sent)>0: for f,now in self.files_not_sent: try: text="Motion detected in your room at {}. Please see attached video.\n".format(now) sem.send_mail(files=[mp4_folder+f],text=text) self.files_not_sent.remove((f,now)) os.remove(mp4_folder+f) except: continue if time.time()-self.time_last_written>logwrite_th: self.time_last_written=time.time() if len(self.files_not_sent)>0: if self.files_not_sent != self.last_files_not_sent: self.last_files_not_sent=deepcopy(self.files_not_sent) with open(log_dir+log_file,'a') as f: f.write(time.strftime("%a, %d %b %Y %H:%M:%S\n",time.localtime())) f.write(str(self.files_not_sent)) f.write('\n') f.write('\n')