• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.dbFinalize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wrappers.db.dbFinalize函数的典型用法代码示例。如果您正苦于以下问题:Python dbFinalize函数的具体用法?Python dbFinalize怎么用?Python dbFinalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dbFinalize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
  regex=re.compile(r'<input+.*?"\s*/>+',re.DOTALL)
  args = argsFetch()
  finyear=args['finyear']
  if args['limit']:
    limit = int(args['limit'])
  else:
    limit =50000
  if args['musterID']:
    mid=args['musterID']
  else:
    mid=None
  if args['maxProcess']:
    maxProcess=int(args['maxProcess'])
  else:
    maxProcess=1
  additionalFilters=''
  if args['district']:
    additionalFilters+= " and b.districtName='%s' " % args['district']
  if args['block']:
    additionalFilters+= " and b.blockName='%s' " % args['block']
  fullfinyear=getFullFinYear(finyear)
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))
  logger.info("BEGIN PROCESSING...")


  db = dbInitialize(db=nregaDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  tasks = multiprocessing.JoinableQueue()
  results = multiprocessing.Queue()
  if mid is None:
    query="select m.id from musters m,blocks b where m.fullBlockCode=b.fullBlockCode and m.finyear='%s' and (m.isDownloaded=0  or (m.wdComplete=0 and TIMESTAMPDIFF(HOUR, m.downloadAttemptDate, now()) > 48 )) %s order by isDownloaded,m.downloadAttemptDate limit %s" % (finyear,additionalFilters,str(limit))
  else:
    query="select m.id from musters m where m.id=%s " % str(mid)
  logger.info(query) 
  cur.execute(query)
  noOfTasks=cur.rowcount
  results1=cur.fetchall()
  for row in results1:
    musterID=row[0]
    tasks.put(Task(musterID))  
  
  for i in range(maxProcess):
    tasks.put(None)

  myProcesses=[musterProcess(tasks, results) for i in range(maxProcess)]
  for eachProcess in myProcesses:
    eachProcess.start()
  while noOfTasks:
    result = results.get()
    logger.info(result)
    noOfTasks -= 1


  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:60,代码来源:downloadMusters.py


示例2: main

def main():
  db = MySQLdb.connect(host=dbhost, user=dbuser, passwd=dbpasswd, charset='utf8')
  db = dbInitialize(db='libtech', charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  query="SET NAMES utf8"
  cur.execute(query)
  query="use libtech"
  cur.execute(query)
  query="select bid,completed,name from broadcasts where bid>1000 and error=0 and approved=1 and processed=1 and completed=0 order by bid DESC "
  print query
  cur.execute(query)
  results = cur.fetchall()
  for row in results:
    bid=str(row[0])
    completed=str(row[1])
    name=row[2]
    print bid+"  "+name+"  "+completed
    query="select a.district,a.block,a.panchayat,c.phone,DATE_FORMAT(c.callStartTime,'%d-%M-%Y') callTime,c.status,c.attempts,c.duration,c.durationPercentage,f.feedback,c.sid from addressbook a,callSummary c left join callFeedback f on c.sid=f.sid where c.phone=a.phone and bid="+str(bid)
    if(completed == '0' or completed=='1'):
      csvname=broadcastReportFilePath+str(bid)+"_"+name.replace(' ',"")+".csv"
      print csvname
      writecsv(cur,query,csvname)
      updateBroadcastTable(cur,bid)
    query="select bid,vendor,phone,callStartTime,duration,vendorCallStatus,cost from callLogs where bid=%s order by phone" % str(bid) 
    if(completed == '0' or completed=='1'):
      csvname=broadcastReportFilePath+str(bid)+"_"+name.replace(' ',"")+"_detailed.csv"
      print csvname
      writecsv(cur,query,csvname)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:32,代码来源:broadcastReport.py


示例3: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  db = dbInitialize(db=nregaDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  if args['updateMusterStats']:
    updateMusterStats(cur,logger) 
  if args['selectRandomDistricts']:
    selectRandomDistricts(cur,logger)
  if args['updatePanchayatStats']:
    updatePanchayatStats(cur,logger)
  if args['genMusterURL']:
    genMusterURLs(cur,logger,args['musterID'])
  if args['downloadRejectedPaymentReport']:
    if args['finyear']:
      finyear=args['finyear']
    else:
      finyear='17'
    downloadRejectedPaymentReport(cur,logger,finyear)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:27,代码来源:houseKeepying.py


示例4: main

def main():
  print 'Content-type: text/html'
  print 
  myhtml=''  
  form = cgi.FieldStorage()
  additionalFilter=''
  districtName=''
  if form.has_key('district'):# is not None:
    additionalFilter+=" and b.districtName='%s' " % form["district"].value
    districtName=form["district"].value
  finyear='17'
  if form.has_key('finyear'):# is not None:
    finyear=form["finyear"].value 
  db = dbInitialize(db="nicnrega", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  finyear='17' 
  
   
  myhtml+=  getCenterAligned('<h2 style="color:blue"> %s</h2>' % (districtName.upper()))

  myhtml+=  getCenterAligned('<h3 style="color:red"> Pending Muster Download MusterWise</h3>')
  query="select m.id,m.musterNo,b.districtName district,b.blockName block,m.wdError,TIMESTAMPDIFF(HOUR,m.downloadAttemptDate,NOW()) timeDiff,m.crawlDate,m.downloadAttemptDate from musters m,blocks b,panchayats p  where m.finyear='%s' and b.isRequired=1 and m.fullBlockCode=b.fullBlockCode and m.stateCode=p.stateCode and m.districtCode=p.districtCode and m.blockCode=p.blockCode and m.panchayatCode=p.panchayatCode and p.isRequired=1  and m.musterType='10' and (m.isDownloaded=0 or m.wdError=1 or (m.wdComplete=0 and TIMESTAMPDIFF(HOUR, m.downloadAttemptDate, now()) > 48 ) ) %s order by isDownloaded,TIMESTAMPDIFF(HOUR,m.downloadAttemptDate,NOW()) DESC limit 4" % (finyear,additionalFilter)
  query_table = "<br />"
  query_table += bsQuery2HtmlV2(cur, query, query_caption="")
  myhtml+=query_table
 
  myhtml=htmlWrapper(title="NREGA Status", head='<h1 aling="center">Nrega Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:33,代码来源:crawlStatus.py


示例5: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))

  logger.info("BEGIN PROCESSING...")
  db = dbInitialize(db="biharPDS", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  inyear=args['year']
  
  logger.info(inyear)
  display = displayInitialize(args['visible'])
  driver = driverInitialize(args['browser'])
  
  #Start Program here
  url="http://www.google.com"
  driver.get(url)
  myhtml=driver.page_source
  print myhtml
  # End program here

  driverFinalize(driver)
  displayFinalize(display)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors


  
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:33,代码来源:exampleSelenium.py


示例6: main

def main():
  print 'Content-type: text/html'
  print 
  myhtml=''  
  
  db = dbInitialize(db="crawlDistricts", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  section_html = getButtonV2('./crawlStatus.py', 'status', 'status')
  query="select name from districts"
  hiddenNames=['districtName'] 
  hiddenValues=[0]
  query_table = "<br />"
  query_table += bsQuery2HtmlV2(cur, query, query_caption="",extraLabel='status',extra=section_html,hiddenNames=hiddenNames,hiddenValues=hiddenValues)
  myhtml+=query_table
  

  myhtml=htmlWrapper(title="NREGA Status", head='<h1 aling="center">Nrega Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:districts.py


示例7: checkAudioFiles

def checkAudioFiles(logger):
  logger.info("Checking if all AudioFiles are present or not")
  db = dbInitialize(host=pdsDBHost,db=pdsDB, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  query="select id,fpsCode from fpsShops where cRequired=1 order by id desc "
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    rowid=str(row[0])
    fpsCode=row[1]
    logger.info("row id: %s dpsCode: %s  " % (rowid,fpsCode))
    audioPresent=1
    fpsFileName="%s/fps/%s.wav" % (pdsAudioDir,fpsCode)
    if not os.path.isfile(fpsFileName):
      audioPresent=0
    logger.info("THe audioPresent : %s " % str(audioPresent))
    query="update fpsShops set audioPresent=%s where id=%s " % (str(audioPresent),rowid)
    cur.execute(query)
    query="update fpsStatus set audioPresent=%s where fpsCode=%s " % (str(audioPresent),fpsCode)
    cur.execute(query)
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:pdsReport.py


示例8: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))
  db = dbInitialize(db="libtech", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  
  query="select phone,bid from callLogs where DATE(callStartTime) = CURDATE() group by phone "
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    #rowid=str(row[0])
    phone=row[0]
    logger.info("  Phone %s " % (phone)) 
    query="select count(*) from callLogs where phone='%s'" % (phone)
    totalCalls=singleRowQuery(cur,query)
    query="select count(*) from callLogs where phone='%s' and status='pass'" % (phone)
    totalSuccessCalls=singleRowQuery(cur,query)
    if totalCalls > 0:
      logger.info("Calculating Percentage")
      successP=math.trunc(totalSuccessCalls*100/totalCalls)
    else:
      successP=0
    logger.info("Total Calls %s Success Calls %s Success Percentage %s " % (str(totalCalls),str(totalSuccessCalls),str(successP)))
    query="update addressbook set totalCalls='%s',successPercentage='%s'  where phone='%s' " % (str(totalCalls),str(successP),phone) 
    cur.execute(query)

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:34,代码来源:updateCallStats.py


示例9: main

def main():
  print 'Content-type: text/html'
  print 

  form = cgi.FieldStorage()
  with open('/tmp/z.txt', 'w') as outfile:
    outfile.write(str(form))

  sid = form['CallSid'].value
  phone = form['From'].value
  digits = form['digits'].value.replace('"','')

  import os

  db = dbInitialize(db="libtech")
  cur = db.cursor()
  query="select a.filename,b.bid from broadcasts b, audioLibrary a where b.bid=%s and b.fileid=a.id" % (digits);
  cur.execute(query)
  row=cur.fetchone()
  filename=row[0]
  
  query = 'insert into testBroadcast (sid,vendor,phone,callStartTime,bid,filename) values ("%s", "exotel","%s", now(), "%s","%s")' % (sid, phone,digits,filename)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(query)
  cur.execute(query)
  dbFinalize(db)

  return 0
开发者ID:rajesh241,项目名称:libtech,代码行数:28,代码来源:exotelTestBroadcast.py


示例10: sql2json

def sql2json(logger,):
  db = dbInitialize(db="surguja", charset="utf8")

  query = 'select id, panchayatName, name, jobcard, musterNo, workCode, accountNo, bankNameOrPOName, musterStatus from workDetails limit 10'
  cur = db.cursor()
  cur.execute(query)
  res = fetchindict(cur)
  logger.info("Converting query[%s]" % query)
  #data = str(res[0]).encode('utf-8')
  data = res
  logger.info("Data[%s]" % data)

  '''
  with open(filename, 'wb') as outfile:
      logger.info('Writing to file[%s]' % filename)
      outfile.write(res)
  '''

  with open(filename, 'w') as outfile:
    logger.info('Writing to file[%s]' % filename)
    json.dump(data, outfile, ensure_ascii=False, indent=4)
      
  dbFinalize(db)

  return 'SUCCESS'
开发者ID:rajesh241,项目名称:libtech,代码行数:25,代码来源:mysql2json.py


示例11: main

def main():
  print 'Content-type: text/plain'
  print 
  db = dbInitialize(db='libtech')
  cur = db.cursor()
  form = cgi.FieldStorage()
# phone=form['From'].value
# sid=form['CallSid'].value
# last10Phone=phone[-10:]
  digits=form['digits'].value
  digits=digits.strip('"')
  with open('/tmp/bihar1.txt', 'w') as outfile:
    outfile.write(str(form)+digits)
 # digits='12380030041412'
  fpsCode=digits[:-2]
  month=int(digits[-2:])

  audioFiles=getPDSAudioList(fpsCode,month)
  if audioFiles is not None:
    audioFileList=audioFiles.split(',')
    s=''
    for audioID in audioFileList:
      query="select filename from audioLibrary where id=%s " % str(audioID)
      cur.execute(query)
      row=cur.fetchone()
      audio=row[0]
      s+=audio
      print "http://callmgr.libtech.info/open/audio/%s" % audio;
    with open('/tmp/bihar.txt', 'w') as outfile:
      outfile.write(str(form)+s)
  else:
    audioFile="spss_try_again.wav"
    print "http://callmgr.libtech.info/open/audio/prompts/%s" % audioFile
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:34,代码来源:biharPDSTest.py


示例12: main

def main():
  print 'Content-type: text/html'
  print 
 
  db = dbInitialize(db="biharPDS", charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  
  queryFilter=' and ' 
  distCodeValue='000'
  blockCodeValue='000'
  fpsCodeValue='000' 
  noInputPassed=1
  form = cgi.FieldStorage()
  if form.has_key('distCode'):
    noInputPassed=0
    distCodeValue=form["distCode"].value
    queryFilter+="p.distCode = '%s' and " %(distCodeValue)
    if form.has_key('blockCode'):
      blockCodeValue=form["blockCode"].value
      if blockCodeValue != '000':
        noInputPassed=0
        queryFilter+="p.blockCode = '%s' and " %(blockCodeValue)
      if form.has_key('fpsCode'):
        fpsCodeValue=form["fpsCode"].value
        if fpsCodeValue != '000':
          noInputPassed=0
          queryFilter+="p.fpsCode = '%s' and " %(fpsCodeValue)
  
  if noInputPassed == 1: 
    queryFilter=queryFilter.lstrip(' and')
  queryFilter=queryFilter.rstrip('and ') 
   
  myhtml=""
  myform=getButtonV2("./shopStatus.py", "biharPDS", "Submit") 
  extraInputs=''
  extraInputs+=getInputRow(cur,"distCode",distCodeValue)
  extraInputs+=getInputRow(cur,"blockCode",blockCodeValue,distCodeValue)
  extraInputs+=getInputRow(cur,"fpsCode",fpsCodeValue,distCodeValue,blockCodeValue)
  myform=myform.replace("extrainputs",extraInputs)

  
  query_table=''
  query_table+="<center><h2>Download Status </h2></center>"
  query="select p.distName,p.blockName,p.fpsName,ps.fpsMonth,ps.fpsYear,ps.downloadAttemptDate,ps.statusRemark from pdsShops p, pdsShopsDownloadStatus ps where p.distCode=ps.distCode and p.blockCode=ps.blockCode and p.fpsCode=ps.fpsCode %s limit 30" %(queryFilter)
  query_table += bsQuery2HtmlV2(cur, query)
 
  query_table+="<center><h2>Detailed Information</h2></center>"
  query="select p.distName,p.blockName,p.fpsName,psms.fpsMonth,psms.fpsYear,psms.scheme,psms.status,psms.sioStatus,psms.driverName0,psms.vehicle0,psms.dateOfDelivery0 from pdsShops p, pdsShopsMonthlyStatus psms where p.distCode=psms.distCode and p.blockCode=psms.blockCode and p.fpsCode=psms.fpsCode %s order by dateOfDelivery0 DESC limit 100" %(queryFilter)
  query_table += bsQuery2HtmlV2(cur, query)
 
  myhtml+=myform
  #myhtml+=query
  myhtml+=query_table
 

  myhtml=htmlWrapper(title="Shop Status", head='<h1 aling="center">Bihar PDS Shop Status</h1>', body=myhtml)
  print myhtml.encode('UTF-8')
  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
开发者ID:rajesh241,项目名称:libtech,代码行数:59,代码来源:shopStatus.py


示例13: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))

  logger.info("BEGIN PROCESSING...")
  if args['district']:
    districtName=args['district'].lower()
  if args['limit']:
    limitString=" limit %s " % (str(args['limit']))
  else:
    limitString="  "
  if args['reportID']:
    reportIDFilter= " and id = %s " % args['reportID']
  else:
    reportIDFilter= " "
  db = dbInitialize(db=districtName.lower(), charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  crawlIP,stateName,stateCode,stateShortCode,districtCode=getDistrictParams(cur,districtName)

  htmlDir=nregaDir.replace("districtName",districtName.lower())

  #block Reports
  query="select b.name,b.blockCode from blocks b where b.isRequired=1 %s" % limitString
  #query="select b.name,b.blockCode from blocks b where b.isRequired=1 limit 1"
  #query="select b.name,b.blockCode,p.name,p.panchayatCode from panchayats p, blocks b where b.blockCode=p.blockCode and p.isRequired=1 limit 1"
  #query="select b.name,b.blockCode,p.name,p.panchayatCode from panchayats p, blocks b where b.blockCode=p.blockCode and p.isRequired=1 and b.blockCode='005' "
#  query="select b.name,b.blockCode,p.name,p.panchayatCode from panchayats p, blocks b where b.blockCode=p.blockCode and p.isRequired=1 and b.blockCode='003' and panchayatCode='013'"
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    blockName=row[0]
    blockCode=row[1]
    genReport(cur,logger,1,htmlDir,'16',districtName,blockCode,blockName,'','',reportIDFilter) 
    genReport(cur,logger,1,htmlDir,'17',districtName,blockCode,blockName,'','',reportIDFilter) 
    genReport(cur,logger,1,htmlDir,'all',districtName,blockCode,blockName,'','',reportIDFilter) 
 
  query="select b.name,b.blockCode,p.name,p.panchayatCode from panchayats p, blocks b where b.blockCode=p.blockCode and p.isRequired=1 %s" % limitString
  #query="select b.name,b.blockCode,p.name,p.panchayatCode from panchayats p, blocks b where b.blockCode=p.blockCode and p.isRequired=1 limit 1"
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    blockName=row[0]
    blockCode=row[1]
    panchayatName=row[2]
    panchayatCode=row[3]
    finyear='16'
    genReport(cur,logger,0,htmlDir,'16',districtName,blockCode,blockName,panchayatCode,panchayatName,reportIDFilter) 
    genReport(cur,logger,0,htmlDir,'17',districtName,blockCode,blockName,panchayatCode,panchayatName,reportIDFilter) 
    genReport(cur,logger,0,htmlDir,'all',districtName,blockCode,blockName,panchayatCode,panchayatName,reportIDFilter) 

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:mayankrungta,项目名称:libtech,代码行数:58,代码来源:genPanchayatReports.py


示例14: processMissedCalls

def processMissedCalls(logger, dir, url, query=None):
  '''
  Process any missed calls in the libtech DB
  '''
  db = dbInitialize(db="libtech")
  cur = db.cursor()

  logger.info("BEGIN PROCESSING...")
  
  if query == None:
    query = '''SELECT log.id, log.missedCallID, log.phone, log.ts, log.jobcard, log.workerID,
    log.payOrderList, log.name, log.complaintNumber, log.complaintDate, log.problemType,
    log.periodInWeeks, log.remarks, log.currentStep, log.finalStatus, log.closureReason,
    log.redressalRemarks, log.rdCallCenterStatus
    FROM ghattuMissedCallsLog AS log
    RIGHT JOIN(
       SELECT missedCallID, max(ts) AS ts FROM ghattuMissedCallsLog
          WHERE htmlgen=0 GROUP BY missedCallID
             ) AS filter
    ON (log.missedCallID = filter.missedCallID and log.ts = filter.ts)'''

  logger.info("query[%s]" % query)
           
  cur.execute(query)
  missedCalls = cur.fetchall()
  logger.debug("missedCalls[%s]" % str(missedCalls))
  for log_details in missedCalls:
    #Put error checks in place and only then update libtech DB

    logger.info("log_details[%s]" % str(log_details))

    if True:
      createGrievanceForms(logger, db, log_details, dir, url)
    elif False:
      oldFetchJobcard(logger, driver, log_details, dir, url)
    else:
      id = log_details[1]
      phone = log_details[2]
      jobcard = log_details[4]
    
      cmd = '/home/mayank/libtech/scripts/fetch -j ' + str(jobcard) + ' -m ' + str(phone) + ' -i ' + str(id) + ' -d ' + dir
      logger.info("cmd[%s]" % cmd)
      os.system(cmd)    

    id = log_details[0]
    query = 'update ghattuMissedCallsLog set htmlgen=1 where id=' + str(id)
    try:    
      cur = db.cursor()
      logger.info("query[%s]" % query)
      cur.execute(query)
    except Exception as e:
      logger.info("query[%s] with exception[%s]" % (query, e))

  dbFinalize(db)
  logger.info("...END PROCESSING")
开发者ID:rajesh241,项目名称:libtech,代码行数:55,代码来源:grievanceCallProcess.py


示例15: main

def main():
  print 'Content-type: text/html'
  print 
  dirname="/home/libtech/webroot/callmgr.libtech.info/open/audio/libtechFlow/"
  outputdirname="/home/libtech/webroot/callmgr.libtech.info/open/audio/"
  db = dbInitialize(db="libtech")
  cur = db.cursor()
  form = cgi.FieldStorage()
  with open('/tmp/z.txt', 'w') as outfile:
    outfile.write(str(form))

  sid = form['CallSid'].value
  phone = form['From'].value
  last10Phone=phone[-10:]
  #upload_date = form['CurrentTime'].value
  upload_date=''
  urlString = form['RecordingUrl'].value
  urlArray=urlString.split(',')
  url=urlArray[-1]
  mp3_file = url.split('/')[-1]
  wave_file = mp3_file.replace('.mp3', '.wav')
  filename = mp3_file.replace('.mp3', '')
  query="insert into audioLibrary (name) values ('%s')" % filename
  cur.execute(query)
  audioID=str(cur.lastrowid)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write("Before CMD audioID[%s],sid[%s], phone[%s],  upload_date[%s], url[%s], mp3_file[%s], wave_file[%s]" % (audioID,sid, phone,  upload_date, url, mp3_file, wave_file))

  import os
  cmd = 'cd %s && wget %s' % (dirname,url)
  os.system(cmd)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(str(cmd))
  wave_fileName="%s_%s.wav" % (audioID,filename)
  query="update audioLibrary set filename='%s' where id=%s " % (wave_fileName,audioID)
  cur.execute(query)
  cmd = 'cd ' + dirname + ' && ffmpeg -i ' + mp3_file + ' -ac 1 -ar 8000 ' + outputdirname+wave_fileName
  os.system(cmd)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(str(cmd))

  query = 'insert into exotelRecordings (sid, filename, recordCreateDate, url, phone, exotelUploadDate, exotelRecordingGood) values ("%s", "%s", now(), "%s", "%s", NOW(),1)' % (sid, wave_fileName, url, last10Phone)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(query)
  cur.execute(query)
  dbFinalize(db)

  '''
  cmd = 'cd /home/libtech/webroot/broadcasts/audio/surgujaVoiceRecordingMP3 && cp ../' + wave_file + ' current.wav'
  os.system(cmd)
  with open('/tmp/z.txt', 'a') as outfile:
    outfile.write(cmd)
  '''

  return 0
开发者ID:rajesh241,项目名称:libtech,代码行数:55,代码来源:voiceRecording.py


示例16: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))

  logger.info("BEGIN PROCESSING...")

  limitString=''
  if args['limit']:
    limitString=' limit '+args['limit']
  if args['district']:
    districtName=args['district']
 
  logger.info("DistrictName "+districtName)
  finyear=args['finyear']
  
  db = dbInitialize(db=districtName.lower(), charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  logger.info("finyear "+finyear)
  fullFinYear=getFullFinYear(finyear) 
  crawlIP,stateName,stateCode,stateShortCode,districtCode=getDistrictParams(cur,districtName)
#Query to get all the blocks



  ftorawfilepath=nregaRawDataDir.replace("districtName",districtName.lower())
  query="select id,blockCode,name from blocks order by rejectedPaymentDownloadDate DESC"
  cur.execute(query)
  results=cur.fetchall()
  for row in results:
    rowid=str(row[0])
    blockCode=row[1]
    blockName=row[2]
    fullBlockCode=stateCode+districtCode+blockCode
    fullDistrictCode=stateCode+districtCode
    url="http://164.100.129.4/netnrega/FTO/rejection.aspx?lflag=eng&state_code=%s&state_name=%s&district_code=%s&page=d&Block_code=%s&Block_name=%s&district_name=%s&fin_year=%s&typ=I&linkr=X"  % (stateCode,stateName.upper(),fullDistrictCode,fullBlockCode,blockName.upper(),districtName.upper(),fullFinYear)
    logger.info(url)
    r=requests.get(url)
    time.sleep(300)
    inhtml=r.text
    ftorawfilename=ftorawfilepath+blockName.upper()+"/FTO/"+fullFinYear+"/rejected.html"
    writeFile(ftorawfilename,inhtml)
    query="update blocks set rejectedPaymentDownloadDate=NOW() where id=%s" % rowid
    logger.info(query)
    cur.execute(query)


  dbFinalize(db) # Make sure you put this if there are other exit paths or errors
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:54,代码来源:downloadRejectedReports.py


示例17: run

 def run(self):
     proc_name = self.name
     while True:
         next_task = self.task_queue.get()
         if next_task is None:
             self.task_queue.task_done()
             dbFinalize(self.pyConn) # Make sure you put this if there are other exit paths or errors
             break            
         answer = next_task(connection=self.pyConn)
         self.task_queue.task_done()
         self.result_queue.put(answer)
     return
开发者ID:rajesh241,项目名称:libtech,代码行数:12,代码来源:downloadMusters.py


示例18: main

def main():
  args = argsFetch()
  logger = loggerFetch(args.get('log_level'))
  logger.info('args: %s', str(args))

  logger.info("BEGIN PROCESSING...")
  if args['district']:
    districtName=args['district'].lower()
  finyear=args['finyear']
  db = dbInitialize(db=districtName, charset="utf8")  # The rest is updated automatically in the function
  cur=db.cursor()
  db.autocommit(True)
  #Query to set up Database to read Hindi Characters
  query="SET NAMES utf8"
  cur.execute(query)
  limitString=''
  if args['limit']:
    limitString="limit "+str(args['limit'])
   
# if args['copyPhones']:
#   logger.info("Copying Phones from libtech to Surguja Database")
#   copyPhones(cur,logger)
# if args['updateRejectionReason']:
#   logger.info("This loop will update RejectionReason")
#   updateRejectionReason(cur,logger,districtName)
# if args['updateFinYear']:
#   logger.info("This loop will update financial year in workDetails")
#   updateFinYear(cur,logger,districtName,limitString)
  if args['revertFTOInformation']:
    logger.info("This loop will update FTO Information")
    if args['revertWorkID']:
      wdID=args['revertWorkID']
      revertFTOInformation(cur,logger,wdID)
    else:
      query="select id from workDetails where finyear='%s' order by id DESC %s" % (finyear,limitString)
      cur.execute(query)
      results=cur.fetchall()
      for row in results:
        wdID=row[0]
        revertFTOInformation(cur,logger,wdID)
  if args['updateJCNumber']:
    logger.info("This will update jcNumber")
    updateJCNumber(cur,logger,districtName,finyear,limitString)
# if args['updatePrimaryAccountHolder']:
#   logger.info("This loop will update Primary Account Holder")
#   updatePrimaryAccountHolder(cur,logger,districtName)

  dbFinalize(db) # Make sure you put this if there are other exit paths or errors


  
  logger.info("...END PROCESSING")     
  exit(0)
开发者ID:rajesh241,项目名称:libtech,代码行数:53,代码来源:houseKeeping.py


示例19: lookupInitialize

def lookupInitialize(logger):
  db = dbInitialize(host=dbhost, user=dbuser, passwd=dbpasswd, db="mahabubnagar")
  cur = db.cursor()

  query = 'select name, jobcardPrefix from panchayats'
  logger.info('query[%s]' % query)
  cur.execute(query)
  jobcard_mapping = cur.fetchall()
  logger.debug('mapping tupple[%s]' % str(jobcard_mapping))
  
  dbFinalize(db)
  return dict((panchayat, jobcardPrefix) for panchayat, jobcardPrefix in jobcard_mapping)
开发者ID:rajesh241,项目名称:libtech,代码行数:12,代码来源:musters.py


示例20: main

def main():
  print 'Content-type: text/html'
  print 

  form = cgi.FieldStorage()
  with open('/tmp/y.txt', 'w') as outfile:
    outfile.write(str(form))
    
  sid = form['CallSid'].value
  phone = form['From'].value
  digits = form['digits'].value
  upload_date = form['CurrentTime'].value
  url = form['RecordingUrl'].value
  mp3_file = url.split('/')[-1]
  wave_file = mp3_file.replace('.mp3', '.wav')
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write("Before CMD sid[%s], phone[%s], digits[%s], upload_date[%s], url[%s], mp3_file[%s], wave_file[%s]" % (sid, phone, digits, upload_date, url, mp3_file, wave_file))

  name = phone + '_' + wave_file.strip('.wav')
  
  db = dbInitialize(db="libtech")
  cur = db.cursor()
  query="update exotelRecordings set inputCode='%s' where sid='%s'" % (str(digits),str(sid))
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write(query)
  cur.execute(query)
  query = 'insert into audioLibrary (name) values ("%s")' % (name)
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write(query)
#  cur.execute(query)
  query = 'select id from audioLibrary where name="%s"' % (name)
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write(query)
#  cur.execute(query)
  id = '12345' # Mynk
  filename = id + '_' + phone
  query = 'update audioLibrary filename="%s" where name="%s"' % (filename, name)
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write(query)
#  cur.execute(query)

  query = 'insert into broadcasts (name, ts, fileid) values ("%s", now(), "%s")' % (name, id)
  with open('/tmp/y.txt', 'a') as outfile:
    outfile.write(query)
#  cur.execute(query)

  dbFinalize(db)

                  

  return 0
开发者ID:rajesh241,项目名称:libtech,代码行数:51,代码来源:exotelCollectBroadcastGarkoos.py



注:本文中的wrappers.db.dbFinalize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.dbInitialize函数代码示例发布时间:2022-05-26
下一篇:
Python wrappers.expect_exact函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap