def delete_element(ar, elem): if elem is None: raise Warning("Cannot delete None") msg = ar.actor.disable_delete(elem, ar) if msg is not None: ar.error(None, msg, alert=True) return settings.SITE.kernel.render_action_response(ar) #~ dblogger.log_deleted(ar.request,elem) #~ changes.log_delete(ar.request,elem) dd.pre_ui_delete.send(sender=elem, request=ar.request) try: elem.delete() except Exception as e: dblogger.exception(e) msg = _("Failed to delete %(record)s : %(error)s.") % dict( record=dd.obj2unicode(elem), error=e) #~ msg = "Failed to delete %s." % element_name(elem) ar.error(None, msg) return settings.SITE.kernel.render_action_response(ar) #~ raise Http404(msg) return HttpResponseDeleted()
def main(*args, **options): if len(args) != 1: raise CommandError("Please specify the path to your TIM changelog directory") data_dir = args[0] # ~ msg = "Started watch_tim %s on %s ..." # ~ dblogger.info(msg,data_dir) # ~ dblogger.info(msg,lino.__version__,data_dir) settings.SITE.startup() # ~ def goodbye(): # ~ msg = "Stopped watch_tim %s on %s ..." # ~ dblogger.info(msg,data_dir) # ~ dblogger.info(msg,lino.__version__,data_dir) # ~ # signal.signal(signal.SIGTERM,on_SIGTERM) # ~ atexit.register(goodbye) # ~ last_warning = None while True: try: watch(data_dir) except Exception, e: dblogger.exception(e) connection.close() time.sleep(1)
def delete_element(ar, elem): if elem is None: raise Warning("Cannot delete None") msg = ar.actor.disable_delete(elem, ar) if msg is not None: ar.error(None, msg, alert=True) return settings.SITE.kernel.render_action_response(ar) #~ dblogger.log_deleted(ar.request,elem) #~ changes.log_delete(ar.request,elem) dd.pre_ui_delete.send(sender=elem, request=ar.request) try: elem.delete() except Exception as e: dblogger.exception(e) msg = _("Failed to delete %(record)s : %(error)s." ) % dict(record=dd.obj2unicode(elem), error=e) #~ msg = "Failed to delete %s." % element_name(elem) ar.error(None, msg) return settings.SITE.kernel.render_action_response(ar) #~ raise Http404(msg) return HttpResponseDeleted()
def load_dbf(dbpath, tableName, load): fn = os.path.join(dbpath, '%s.DBF' % tableName) f = dbfreader.DBFFile(fn, codepage="cp850") dblogger.info("Loading %d records from %s...", len(f), fn) f.open() for dbfrow in f: i = load(dbfrow) if i is not None: i = settings.TIM2LINO_LOCAL(tableName, i) if i is not None: try_full_clean(i) try: i.save() #~ dblogger.debug("%s has been saved",i) except Exception, e: #~ except IntegrityError,e: dblogger.warning( "Failed to save %s from %s : %s", obj2str(i), dbfrow, e) dblogger.exception(e)
def delete_element(ar,elem): assert elem is not None msg = ar.actor.disable_delete(elem,ar) if msg is not None: rv = ar.ui.error(None,msg,alert=True) return ar.ui.action_response(rv) #~ dblogger.log_deleted(ar.request,elem) #~ changes.log_delete(ar.request,elem) dd.pre_ui_delete.send(sender=elem,request=ar.request) try: elem.delete() except Exception,e: dblogger.exception(e) msg = _("Failed to delete %(record)s : %(error)s." ) % dict(record=obj2unicode(elem),error=e) #~ msg = "Failed to delete %s." % element_name(elem) rv = ar.ui.error(None,msg) return ar.ui.action_response(rv)
i = 0 for ln in fd_watching.readlines(): i += 1 dblogger.debug("process_line(%r,%r)", i, ln) try: process_line(ln) except Exception, e: # ~ raise fd_failed.write("// %s %r\n%s\n\n" % (time.strftime("%Y-%m-%d %H:%M:%S"), e, ln)) # ~ fd_failed.write(ln+'\n') # ~ dblogger.warning("%s:%d: %r\nin changelog line %s", watching,i,e,ln) dblogger.warning("Exception '%r' while processing changelog line:\n%s", e, ln) # for ValidationError we don't want a full traceback with mail to # the admins. if not isinstance(e, IGNORABLE_ERRORS): dblogger.exception(e) # ~ raise fd_watching.close() fd_failed.close() os.remove(watching) dblogger.info("%d changes have been processed.", i) # ~ log.close() def main(*args, **options): if len(args) != 1: raise CommandError("Please specify the path to your TIM changelog directory") data_dir = args[0] # ~ msg = "Started watch_tim %s on %s ..." # ~ dblogger.info(msg,data_dir) # ~ dblogger.info(msg,lino.__version__,data_dir)