Esempio n. 1
0
def getUsers():
  """Writes basic information about users to a CSV file."""
  token = agollib.getToken()[0]
  siteInfo = agollib.SubscriptionProperties(token)
  results = siteInfo.getUsers(token)
  space = siteInfo.storage
  with open(OUTNAME,'w') as f:
    f.write('"USERNAME","ROLE","USAGE","QUOTA","PCTQUOTA","PCTSITEUSE","PCTSITEQUOTA"'\
            ',"CREATED","MODIFIED","FULLNAME","EMAIL"\n')
    
    for user in results:
      f.write("\""+user[u'username']+"\","+
              "\""+user[u'role']+"\","+
              str(user[u'storageUsage'])+","+
              str(user[u'storageQuota'])+","+
              getRatio(user[u'storageUsage'], user[u'storageQuota'], percent=True)+","+
              getRatio(user[u'storageUsage'], space[0], 4, True)+","+
              getRatio(user[u'storageUsage'], space[1], 5, True)+","+
              agollib.getDateTime(user[u'created'])+","+
              agollib.getDateTime(user[u'modified'])+","+
              "\""+user[u'fullName']+"\","+
              "\""+user[u'email']+"\"\n")
      
  f.close()
  print "Basic user stats written to", OUTNAME
  return
Esempio n. 2
0
def getSiteItems():
  """Writes basic statistics about all user-owned items to a CSV file."""
  outfile = "items.csv"
  token = agollib.getToken()[0]
  siteInfo = agollib.SubscriptionProperties(token)
  results = siteInfo.getItems(token)
  with open(outfile,'w') as f:
    f.write('"OWNER","TITLE","TYPE","ID","SIZE","ACCESS","CREATED","MODIFIED"\n')
    for itemId in results:
      item = results[itemId]
      f.write("\""+item[u'owner']+"\","+
              "\""+item[u'title']+"\","+
              "\""+item[u'type']+"\","+
              "\""+item[u'id']+"\","+
              str(item[u'size'])+","+
              "\""+item[u'access']+"\","+
              agollib.getDateTime(item[u'created'])+","+
              agollib.getDateTime(item[u'modified'])+"\n")

  f.close()
  print "Basic stats on", len(results), " items written to", outfile
  return results