Пример #1
0
def executeQuery(curs, query, quotehash):


  def utf8armor(x):
    if isinstance(x, unicode):
      return x.encode('utf8')
    elif isinstance(x, (list, tuple, dict)):
      return ''
    else:
      return x

  def reunicodify(row):
    newrow= []
    for col in row:
      if isinstance(col, str):
        col= col.decode('utf8')
      newrow.append(col)
    return newrow


  newhash= {}
  for key in quotehash.keys():
    newhash[key]= utf8armor(quotehash[key])
  if settings.has_key('debugSQL'):
    YammerUtils.debugMessage('executing query: %s\n\nnewhash: %s' %
        (query, `newhash`))
  curs.execute(query, newhash)
  return [reunicodify(row) for row in curs.fetchall()]
Пример #2
0
 def gsend(self, signer, to, message, RETURN_RECEIPT=0):
   to_locs= [x for x in to if x[0] != '/']
   to_kwds= [x for x in to if x[0] == '/']
   if len(to_locs) == 0:
     return
   to_locs= map(pygale.expand_aliases, to_locs)
   ret= lookup_all_locations(to_locs)
   (send_locs, bad_locs, encr_recps)= ([], [], [])
   for (loc, recps) in ret:
     if recps is None:
       bad_locs.append(loc)
     else:
       send_locs.append(loc)
       for r in recps:
         if isinstance(r, str):
           encr_recps.append(r)
         else:
           encr_recps.append(r.name())
   if bad_locs:
     raise ValueError, 'Unable to resolve location: ' \
         + string.join(bad_locs) + '.'
   if '' in encr_recps:
     # no point encrypting if we're also sending plaintext
     encr_recps= []
   else:
     if not signer in encr_recps:
       encr_recps.append(signer)
       to_locs.append(signer)
   puff= Puff()
   puff.set_loc(string.join(to_locs))
   u= UserPrefs.getInstance(signer)
   sender= u['gale.sender']
   if sender == '':
     sender= KeyStore.getFullname(signer)
   puff.set_text('message/sender', sender)
   puff.set_time('id/time', int(time.time()))
   puff.set_text('id/class', '%s/%s' % (settings['product'],
                                        YammerUtils.getVersionString()))
   puff.set_text('id/instance', getinstance())
   if RETURN_RECEIPT:
     puff.set_text('question.receipt', signer)
   for kwd in to_kwds:
     puff.set_text('message.keyword', kwd[1:])
   if len(message) > 0 and not message.endswith('\n'):
     message += '\n'
   puff.set_text('message/body', message)
   ret= puff.sign_message(signer)
   if ret is not None:
     # danger
     puff= ret
   if encr_recps:
     ret= puff.encrypt_message(encr_recps)
     if ret is not None:
       # danger
       puff= ret
   self.connect()
   self.transmit_puff(puff)
   self.disconnect()
Пример #3
0
 def generateDebugInfo(self):
   ''' Return HTML-formatted debugging information about the current exception. '''
   self.html= []
   self.bugdesc= "(please click *Edit* and enter a brief description of " + \
     "what you were doing, here)\n\n====\n"
   self.reporttitle= 'unexpected error'
   self.writeHTML()
   html= ''.join(self.html)
   self.html= None
   contact= self.getGaleId()
   if contact:
     contact= 'gale ' + contact
   else:
     contact= ''
   version= YammerUtils.getVersionString()
   desc= self.bugdesc.replace('"', '"')
   title= self.reporttitle
   return ("""<form method="post" action="http://cvstrac.ofb.net/tktnew">
     <input type="hidden" name="t" value="%(title)s">
     <input type="hidden" name="w" value="jtr">
     <input type="hidden" name="c" value="%(contact)s">
     <input type="hidden" name="s" value="yammer.net">
     <input type="hidden" name="v" value="%(version)s">
     <input type="hidden" name="y" value="event">
     <input type="hidden" name="r" value="3">
     <input type="hidden" name="p" value="3">
     <input type="hidden" name="d" value="%(desc)s">
     You can file an incident report about this error.  If you file
     an incident report, relevant information about the problem will
     be saved in the bug database and you will be given a chance to
     type in extra information, such as a description of what you
     were doing.  Filling out an incident report is very helpful and
     makes it much more likely that the developer will be able to fix
     the problem.  If you would like to file an incident report,
     please click here:<p>
     <input type="submit" name="submit" value="submit incident report">
     """ % locals(), html)
Пример #4
0
def filetraces(message, *args):
  fds= os.listdir('/proc/%s/fd' % os.getpid())
  import YammerUtils
  YammerUtils.debugMessage('%s: %d fds (%s)' %
      (message % args, len(fds), ' '.join(fds)))
Пример #5
0
 def release(self):
   threading._RLock.release(self)
   YammerUtils.debugMessage("released lock %s..." % self)
Пример #6
0
 def acquire(self, blocking=1):
   YammerUtils.debugMessage("acquiring lock %s..." % self)
   threading._RLock.acquire(self, blocking)
   YammerUtils.debugMessage("acquired lock %s..." % self)