def __init__(self, cxn=None): cxn = cxn or SharedConnection() self.templates = [] qry = 'SELECT * FROM job_template' res = cxn.execute(qry) for row in res: self.templates.append(self._parseTemplate(row))
def __init__(self, cxn=None): cxn = cxn or SharedConnection() self.jobs = [] qry = 'select job_template.template_name, job_instance.* from job_instance LEFT OUTER JOIN job_template ON (job_instance.template = job_template.id)' res = cxn.execute(qry) for row in res: self.jobs.append(self._parseJob(row))
def handle_server_connection(conn): """ Handle a client connection to the server """ print("connected to server") sc = SharedConnection(conn) sc.is_open = True # create a background thread here for receiving messages and show message sending ui in current thread background_thread = threading.Thread(target=handle_incoming_data, args=(sc, )) background_thread.start() # do gui related work here while sc.is_open: msg = input("send to server> ") sc.send(msg) if 'quit' == msg.strip().lower(): sc.close() background_thread.join()
def handle_client_connection(conn, addr): """ Handle a client connection """ print("Accepted connection from: " + repr(addr)) sc = SharedConnection(conn) sc.is_open = True # create a background thread here for receiving messages and show message sending ui in current thread background_thread = threading.Thread(target=handle_incoming_data, args=(sc, )) background_thread.start() # do gui related work here time.sleep(1) while sc.is_open: msg = input("send to client> ") sc.send(msg) if 'quit' == msg.strip().lower(): sc.close() background_thread.join()
'errors': '0', 'status': 'finished', 'ack': '', 'log': '', 'startts': jobTimes[2], 'lasteventts': jobTimes[2] + datetime.timedelta(minutes=-10), 'lastevent': '' }, ] parser = OptionParser() parser.add_option('--user', default='jobtracker') options, args = parser.parse_args() conninfo = 'dbname=crontracker user={user}'.format(user=options.user) cxn = SharedConnection(conninfo=conninfo, autocommit=True) qry = 'DELETE FROM job_instance' cxn.execute(qry) qry = 'DELETE FROM job_template' cxn.execute(qry) for template in templates: cxn.execute(insertTemplateSQL(template)) for job in jobs: cxn.execute(insertJobRunSQL(job)) templateCollector = TemplateCollector(cxn=cxn) for template in templateCollector:
jobTimes = [now + datetime.timedelta(minutes=-36), now + datetime.timedelta(minutes=-320), now + datetime.timedelta(minutes=-27), ] jobs = [ {'template':'proc_param', 'warnings':'0', 'errors':'0', 'status':'finished', 'ack':'', 'log':'', 'startts':jobTimes[0], 'lasteventts':jobTimes[0], 'lastevent':'start'}, {'template':'log_puller', 'warnings':'0', 'errors':'1', 'status':'finished', 'ack':'', 'log':'', 'startts':jobTimes[1], 'lasteventts':jobTimes[1]+datetime.timedelta(minutes=-5), 'lastevent':'commit'}, {'template':'', 'warnings':'0', 'errors':'0', 'status':'finished', 'ack':'', 'log':'', 'startts':jobTimes[2], 'lasteventts':jobTimes[2]+datetime.timedelta(minutes=-10), 'lastevent':''}, ] parser = OptionParser() parser.add_option('--user', default='jobtracker') options, args = parser.parse_args() conninfo = 'dbname=crontracker user={user}'.format(user=options.user) cxn = SharedConnection(conninfo=conninfo, autocommit=True) qry = 'DELETE FROM job_instance' cxn.execute(qry) qry = 'DELETE FROM job_template' cxn.execute(qry) for template in templates: cxn.execute(insertTemplateSQL(template)) for job in jobs: cxn.execute(insertJobRunSQL(job)) templateCollector = TemplateCollector(cxn=cxn) for template in templateCollector: