def main(): try: pw = open("/usr/share/httpd/.ssh/ep_api_key", "r").read().strip() ep = EtherpadLiteClient(base_params={"apikey": pw}, api_version="1.2.10") except: e = sys.exc_info()[0] print "Problem logging into Etherpad via API: {0}".format(e) sys.exit(1) all_pads = ep.listAllPads() ver_pads = [x for x in all_pads["padIDs"] if "ulb" in x or "udb" in x] ver_pads.sort() redirects = [] for bk in books.iterkeys(): bk_pads = [x for x in ver_pads if bk.lower() in x and contains_digits(x)] bk_pads.sort() for p in bk_pads: # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti') if len(p.split("-")) < 4: continue chapter = p.split("-")[3] content = ep.getText(padID=p)["text"] if "Welcome to Etherpad!" in content: continue redirects.append(u"rewrite /p/{0} /p/{1} permanent;".format(p, ep.getReadOnlyID(padID=p)["readOnlyID"])) print u"\n".join(sorted(redirects))
def main(): try: pw = open('/usr/share/httpd/.ssh/ep_api_key', 'r').read().strip() ep = EtherpadLiteClient(base_params={'apikey': pw}, api_version='1.2.10') except: e = sys.exc_info()[0] print 'Problem logging into Etherpad via API: {0}'.format(e) sys.exit(1) all_pads = ep.listAllPads() ver_pads = [x for x in all_pads['padIDs'] if 'ulb' in x or 'udb' in x] ver_pads.sort() redirects = [] for bk in books.iterkeys(): bk_pads = [ x for x in ver_pads if bk.lower() in x and contains_digits(x) ] bk_pads.sort() for p in bk_pads: # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti') if len(p.split('-')) < 4: continue chapter = p.split('-')[3] content = ep.getText(padID=p)['text'] if 'Welcome to Etherpad!' in content: continue redirects.append(u'rewrite /p/{0} /p/{1} permanent;'.format( p, ep.getReadOnlyID(padID=p)['readOnlyID'])) print u'\n'.join(sorted(redirects))
def main(): try: pw = open('/usr/share/httpd/.ssh/ep_api_key', 'r').read().strip() ep = EtherpadLiteClient(base_params={'apikey': pw}, api_version='1.2.10') except: e = sys.exc_info()[0] print 'Problem logging into Etherpad via API: {0}'.format(e) sys.exit(1) all_pads = ep.listAllPads() ver_pads = [x for x in all_pads['padIDs'] if x.startswith(u'ta-')] ver_pads.sort() redirects = [] for p in ver_pads: content = ep.getText(padID=p)['text'] if 'Welcome to Etherpad!' in content: continue redirects.append(u'rewrite /p/{0} /p/{1} permanent;'.format(p, ep.getReadOnlyID(padID=p)['readOnlyID'])) print u'\n'.join(sorted(redirects))
def main(): try: pw = open('/usr/share/httpd/.ssh/ep_api_key', 'r').read().strip() ep = EtherpadLiteClient(base_params={'apikey': pw}, api_version='1.2.10') except: e = sys.exc_info()[0] print 'Problem logging into Etherpad via API: {0}'.format(e) sys.exit(1) all_pads = ep.listAllPads() ver_pads = [x for x in all_pads['padIDs'] if x.startswith(u'ta-')] ver_pads.sort() redirects = [] for p in ver_pads: content = ep.getText(padID=p)['text'] if 'Welcome to Etherpad!' in content: continue redirects.append(u'rewrite /p/{0} /p/{1} permanent;'.format( p, ep.getReadOnlyID(padID=p)['readOnlyID'])) print u'\n'.join(sorted(redirects))