本文整理汇总了Python中pythonFrame.myUtils.Util.Util.printf方法的典型用法代码示例。如果您正苦于以下问题:Python Util.printf方法的具体用法?Python Util.printf怎么用?Python Util.printf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythonFrame.myUtils.Util.Util
的用法示例。
在下文中一共展示了Util.printf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: monitor_exception_count
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def monitor_exception_count(self, e, isTimeout_retry, url):
if str(e).find('urlopen error timed out') > -1:
if not isTimeout_retry:
self.monitor.urls_serial_timeout.append(url)
else:
self.monitor.urls_retry_failure.append(url)
Util.printf('urlopen-->%s | exception--> %s' % (url, e))
示例2: proxy
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def proxy(self, path, func):
if not self.file_exist(path,True):
return
if func.has_key('preprocess'):
self.preprocess = func.get('preprocess')
if func.has_key('process'):
self.process = func.get('process')
if func.has_key('postprocess'):
self.postprocess = func.get('postprocess')
context = self.preprocess()
file_object = open(path)
try:
for line in file_object:
try:
exitcode = self.process(line, context)
if exitcode == 0:
continue
elif exitcode == -1:
return
except Exception, e:
Util.printf(e)
Util.printf("first item:"+line)
return self.postprocess(context)
示例3: select_map_store
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def select_map_store(self):
map_store={}
table = "video_report_%d" % int(self.monitorReport.mydate.get_now(format='ym'))
fields = []
fiedls_position={}
re=ReportEntity.ReportEntity()
count = 0
for f in re.__dict__:
fields.append(f)
fiedls_position.setdefault(f,count)
count+=1
sql = ' select '
sql += ','.join(fields)
sql += ' from '+ table
sql += ' where dtime='+ self.monitorReport.mydate.get_now() +' and play_plat=2 '
Util.printf(sql)
rows = self.mysql_select(sql)
for row in rows:
video_id= row[fiedls_position.get('video_id')]
report = {}
for k , v in fiedls_position.iteritems():
report.setdefault(k,row[v])
map_store.setdefault(('%d' % video_id),report)
return map_store
示例4: insert_update_report
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def insert_update_report(self, **args):
map_store=args.get("map_store")
update_fields=args.get("update_fields")
table_name = "video_report_%d" % int(self.monitorReport.mydate.get_now(format='ym'))
table_field = []
update_field=[]
datalist = []
table_field_len = 0
for report in map_store.values():
if table_field_len == 0:
for k in report.keys():
table_field.append(k)
table_field_len = len(table_field)
table_value = []
for v in table_field:
table_value.append(report[v])
datalist.append(tuple(table_value))
for field in update_fields:
update_field.append( "%s=values(%s)" % (field,field))
sql_head = ' insert into ' + table_name
sql_body = ' ( ' + ','.join(table_field) + ' ) '
sql_blank = ' , %s ' * (table_field_len - 1)
sql_tail = ' values ( %s ' + sql_blank + ' ) '
sql_duplicate=' ON DUPLICATE KEY UPDATE '+','.join(update_field)
sql = sql_head + sql_body + sql_tail + sql_duplicate
Util.printf(sql)
self.mysql_executemany(sql, datalist)
示例5: get_conn_qs
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def get_conn_qs(self):
try:
conn = MySQLdb.connect(host=self.host, user=self.user, passwd=self.passwd,
db=self.db, charset=self.charset, port=self.port)
return conn
except Exception, e:
Util.printf(e)
示例6: run
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def run(self):
Util.printf("thread running".ljust(50,"."))
while self.isRun:
if not self.q.isEmpty():
Util.printf("proccess running".ljust(50,"."))
singal = str(self.q.get_singal())
p = MyProcess(singal,self.path,self.mysqlWrap,self.constants,self.monitor,self.lock)
self.jobs.setdefault(singal,p)
p.start()
Util.printf("queque pop %s" % singal)
else:
jbs = [job.is_alive() for job in self.jobs.values() ]
if jbs.count(False) == self.jobs_size :
self.isRun = False
if jbs.__len__() == self.jobs_size:
self.isRun = False
if jbs.__len__() > 0 and jbs.__len__() == self.jobs_size - 1:
self.q.put_singal("URLRequest")
jps_show = [(name,job.is_alive()) for name,job in self.jobs.items() ]
Util.printf("current process is_alive:%s" % jps_show)
time.sleep(2)
Util.printf("thread stop".ljust(50,"."))
示例7: monitor_exception_count
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def monitor_exception_count(self, e, isTimeout_retry, url):
if str(e).find("timed out") > -1 or str(e).find("Time-out") > -1:
if not isTimeout_retry:
self.monitor.urls_parallel_timeout.append(url)
else:
self.monitor.urls_retry_failure.append(url)
Util.printf("urlopen-->%s | exception--> %s" % (url, e))
示例8: mysql_select
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def mysql_select(self,sql):
conn = self.get_conn_qs()
cursor = conn.cursor()
try:
n = cursor.execute(sql)
return cursor.fetchall()
except Exception, e:
Util.printf(e)
示例9: oracle_fetchall
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def oracle_fetchall(self, sql):
conn = self.get_conn()
cursor = conn.cursor()
try:
cursor.execute(sql)
rows = cursor.fetchall()
return rows
except Exception, e:
Util.printf(e)
示例10: sub_job_join
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def sub_job_join(self):
while True:
if self.jobs.__len__() == self.jobs_size:
for k,job in self.jobs.items() :
if job.is_alive():
Util.printf(("%s proccess join".ljust(50,".")) % k)
job.join()
break
else:
Util.printf("main proccess sleeping".ljust(50,"."))
time.sleep(10)
示例11: mysql_execute_new
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def mysql_execute_new(self, sql, datalist):
conn = self.get_conn_qs()
cursor = conn.cursor()
try:
for data in datalist:
tmpsql = sql % tuple(data)
n = cursor.execute(sql,tuple(data))
conn.commit()
Util.printf('n=%s | sql=%s' % (n, tmpsql))
except Exception, e:
Util.printf(e)
示例12: read_keyvalue
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def read_keyvalue(self, path):
update_map = {}
self.file_exist(path)
file_object = open(path)
try:
for line in file_object:
kvs = line.split()
if len(kvs) < 2: continue
update_map.setdefault(kvs[0], kvs[1])
return update_map
except Exception, e:
Util.printf(e)
示例13: update_mysql_field
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def update_mysql_field(self, *args):
update_map = args[0]
update_field = args[1]
uids = args[2]
table = "video_report_%d" % int(self.monitorReport.mydate.get_now(format='ym'))
base_sql = "update %s set %s" % (table, update_field)
sql = base_sql + "=%s where dtime=%s and play_plat=2 and video_id=%s and uid=%s"
Util.printf(sql)
datalist = []
for k, v in update_map.items():
datalist.append((v, self.monitorReport.mydate.get_now('-'), k, uids.get(k, 0)))
self.mysql_executemany(sql, datalist)
示例14: mysql_executemany
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def mysql_executemany(self, sql, datalist):
conn = self.get_conn_qs()
cursor = conn.cursor()
try:
datalen = len(datalist) + 1
for i in range(datalen):
if i % 500 == 0:
n = cursor.executemany(sql, datalist[i:500 + i])
Util.printf(n)
conn.commit()
except Exception, e:
Util.printf(e)
import traceback
traceback.print_exc()
示例15: mysql_executemany
# 需要导入模块: from pythonFrame.myUtils.Util import Util [as 别名]
# 或者: from pythonFrame.myUtils.Util.Util import printf [as 别名]
def mysql_executemany(self, sql, datalist):
conn = self.get_conn_qs()
cursor = conn.cursor()
try:
datalen = len(datalist) + 1
for i in range(datalen):
if i % 500 == 0:
n = cursor.executemany(sql, datalist[i:500 + i])
data_leave = datalen - i - 500
prefix = str("data_leave:%s" % data_leave).ljust(20)
postfix = str("| commit_already:%s" % n).ljust(20)
Util.printf(prefix + postfix)
conn.commit()
except Exception, e:
Util.printf(e)
import traceback
traceback.print_exc()