Ejemplo n.º 1
def uploadDir(*argv):
  server = argv[0]
  dbname = argv[1]
  for droot, dpath, fileNames in os.walk(argv[2]):
    for fname in fileNames:
      #print droot, fname
      fullFilePath = os.path.join(droot, fname)
      if os.path.isfile( fullFilePath ):
        if re.match('[0-9]*_[0-9]*.txt', os.path.basename(fullFilePath)) != None:
          print 'uploading', fullFilePath
          up.upload(server, dbname, fullFilePath)
Ejemplo n.º 2
def uploadFileInRange(*argv):
  server = argv[0]
  dbname = argv[1]
  theDir = argv[2]
  startFileName = argv[3]
  endFileName = argv[4]
  dirContents = os.listdir(argv[2])
  for item in dirContents:
    if os.path.isfile(os.path.join(argv[2],item)) and os.path.basename(item) >= startFileName and os.path.basename(item) <= endFileName:
      if re.match('[0-9]*_[0-9]*.txt', os.path.basename(item)) != None:
        print 'uploading', item
        up.upload(server, dbname, os.path.join(argv[2],item))
Ejemplo n.º 3
def main(*argv):
  uri = 'https://%s:%[email protected]' % (argv[0], argv[1])
  dbname = 'radon'
  dataDir = '\\Radon\Data\\'  #this is where i will look for data files. we won't look recursively... just in this directory
  prog = re.compile('[0-9]*?_[0-9]*?.txt')  #this is the expected string pattern
  while True:
    #we get the data file on the database that has the highest
    #run number.
      s = Server(uri)
      db = s[dbname]
      vr = db.view('app/runNumber', reduce =False, limit = 1, descending=True)
      row = vr.first()
        majorRun = row['key'][0]
        minorRun = row['key'][1]
        majorRun = -1
        minorRun = -1
      print 'most recent data %d_%d' % (majorRun, minorRun)
      #now, see if any of the files in the data directory have 
      #a larger run number
      files = os.listdir(dataDir)
      for afile in files:
        if prog.match(afile):  
          majr, minr = afile.strip('.txt').split('_')
          majr = int(majr)
          minr = int(minr)
          #print majr, minr, majorRun, minorRun
          if (majr > majorRun) or (majr == majorRun and minr > minorRun):
            print 'uploading', os.path.join(dataDir, afile)
            up.upload(uri, dbname, os.path.join(dataDir, afile))

      print 'sleeping...', datetime.datetime.now()
      time.sleep(3600)  #wait one hour to look for more data

    except Exception as e:
      print e