def sites_changelog(yesterday, html): html += """ <h4>Sustainablecorn Internal Website Changes</h4> <table border="1" cellpadding="3" cellspacing="0"> <thead><tr><th>Time</th><th>Activity</th></tr></thead> <tbody>""" config = ConfigParser.ConfigParser() config.read('mytokens.cfg') s = util.get_sites_client(config) feed = s.get_activity_feed() tablerows = [] for entry in feed.entry: ts = datetime.datetime.strptime(entry.updated.text, '%Y-%m-%dT%H:%M:%S.%fZ') ts = ts.replace(tzinfo=pytz.timezone("UTC")) # print 'Sites ts: %s' % (ts,) if ts < yesterday: continue updated = ts.astimezone(pytz.timezone("America/Chicago")) elem = entry.summary.html elem.namespace = '' elem.children[0].namespace = '' tablerows.append(("<tr><td>%s</td><td>%s %s</td></tr>\n" ) % (updated.strftime("%-d %b %-I:%M %P"), elem.text, str(elem.children[0]))) if len(tablerows) == 0: tablerows.append("<tr><td colspan='2'>No Changes Found</td></tr>") html += "".join(tablerows) html += """</tbody></table>""" return html
def sites_changelog(regime, yesterday, html): html += """ <h4>%s Internal Website Changes</h4> <table border="1" cellpadding="3" cellspacing="0"> <thead><tr><th>Time</th><th>Activity</th></tr></thead> <tbody>""" % ( CFG[regime]["title"], ) config = ConfigParser.ConfigParser() config.read("mytokens.cfg") site = "sustainablecorn" if regime == "cscap" else "transformingdrainage" s = util.get_sites_client(config, site) # Fetch more results for sites activity feed opt = {"max-results": 999} feed = s.get_activity_feed(**opt) tablerows = [] for entry in feed.entry: ts = datetime.datetime.strptime(entry.updated.text, "%Y-%m-%dT%H:%M:%S.%fZ") ts = ts.replace(tzinfo=pytz.timezone("UTC")) # print 'Sites ts: %s' % (ts,) if ts < yesterday: continue updated = ts.astimezone(pytz.timezone("America/Chicago")) elem = entry.summary.html elem.namespace = "" elem.children[0].namespace = "" tablerows.append( ("<tr><td>%s</td><td>%s %s</td></tr>\n") % (updated.strftime("%-d %b %-I:%M %P"), elem.text, str(elem.children[0])) ) if len(tablerows) == 0: tablerows.append("<tr><td colspan='2'>No Changes Found</td></tr>") html += "".join(tablerows) html += """</tbody></table>""" return html
Sync authorized users on Google Sites to Google Drive """ import gdata.docs.client import gdata.docs.data import gdata.acl.data import gdata.data import ConfigParser import util config = ConfigParser.ConfigParser() config.read('mytokens.cfg') docs_client = util.get_docs_client( config ) spr_client = util.get_sites_client( config ) site_users = [] for acl in spr_client.get_acl_feed().entry: #print "IN: ||%s||" % (acl.scope.value,) userid = acl.scope.value if userid not in site_users: site_users.append( acl.scope.value ) query = gdata.docs.client.DocsQuery(show_collections='true', title='CSCAP Internal Documents') feed = docs_client.GetAllResources(query=query) cscap = feed[0] acl_feed = docs_client.GetResourceAcl( cscap ) for acl in acl_feed.entry: #print acl.role.value, acl.scope.type, acl.scope.value