コード例 #1
0
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))
コード例 #2
0
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))
コード例 #3
0
ファイル: start.py プロジェクト: jerryeechan/clcpilotstudy
def pasteText(text=None):
    a = request.args.get('a')
    c = EtherpadLiteClient(
        base_params={
            'apikey':
            'f42591e743037bc39d530ba6b1550b0d558aed32f3e9f5e8f12cdeaa1a48b0cd'
        })
    padList = c.listAllPads()
    c.appendText(padID=padList['padIDs'][0], text=a)
    return json.dumps('test')
コード例 #4
0
ファイル: start.py プロジェクト: CHI2017LS/CLC_prototyping
def getPadUsersCount(userCount=None):
    c = EtherpadLiteClient(
        base_params={
            'apikey':
            'f42591e743037bc39d530ba6b1550b0d558aed32f3e9f5e8f12cdeaa1a48b0cd'
        })
    # c = EtherpadLiteClient(base_params={'apikey':'555ddf5d51cba5e38e93d538742a02f7d1b2ea968ca4dcccb983f31c954d632b'})
    padList = c.listAllPads()
    userCount = {}

    for ID in padList['padIDs']:
        userCount[ID] = c.padUsersCount(padID=ID)['padUsersCount']

    return json.dumps(userCount)
コード例 #5
0
ファイル: start.py プロジェクト: CHI2017LS/CLC_prototyping
def createPad():
    id = request.args.get('padID')
    print(id)
    c = EtherpadLiteClient(
        base_params={
            'apikey':
            'f42591e743037bc39d530ba6b1550b0d558aed32f3e9f5e8f12cdeaa1a48b0cd'
        })
    padList = c.listAllPads()
    if id in padList['padIDs']:
        c.deletePad(padID=id)
    message = c.createPad(padID=id)
    message = c.setText(padID=id, text="")
    return json.dumps(message)
コード例 #6
0
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()['padIDs']

    for p in all_pads:
        # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti')
        if len(p.split('-')) < 4:
            continue
        content = u'' + ep.getText(padID=p)['text']
        if 'Welcome to Etherpad!' in content or 'ATTENTION' in content:
            continue
        print p
        parts = p.split('-')
        lang = parts[0]
        resource = parts[1]
        bk = parts[2]
        chp = parts[3]
        bk = bk.upper()
        if not bk in books:
            continue
        booknum = books[bk][1]
        content = u'''——————————————————————————————————————
!!!!
!!!!                                                           ATTENTION!!
!!!!          *** THESE FILE ARE NO LONGER EDITED ON ETHERPAD! ***
!!!!
!!!! PLEASE CREATE AN ACCOUNT AT http://github.com AND LET US KNOW YOUR USERNAME
!!!! ON SLACK IN THE #resources CHANNEL OR EMAIL [email protected]
!!!!
!!!! ONCE YOU HAVE ACCESS, YOU CAN EDIT THIS FILE AT
!!!! https://github.com/Door43/{0}-{1}/blob/master/{2}-{3}/{4}.usfm
!!!!
——————————————————————————————————————

{5}
'''.format(resource, lang, booknum, bk, chp, content)
        print p
        ep.setText(padID=p, text=content.encode('utf-8'))
コード例 #7
0
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()['padIDs']

    for p in all_pads:
        # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti')
        if len(p.split('-')) < 4:
            continue
        content = u''+ep.getText(padID=p)['text']
        if 'Welcome to Etherpad!' in content or 'ATTENTION' in content:
            continue
        print p
        parts = p.split('-')
        lang = parts[0]
        resource = parts[1]
        bk = parts[2]
        chp = parts[3]
        bk = bk.upper()
        if not bk in books:
            continue
        booknum = books[bk][1]
        content = u'''——————————————————————————————————————
!!!!
!!!!                                                           ATTENTION!!
!!!!          *** THESE FILE ARE NO LONGER EDITED ON ETHERPAD! ***
!!!!
!!!! PLEASE CREATE AN ACCOUNT AT http://github.com AND LET US KNOW YOUR USERNAME
!!!! ON SLACK IN THE #resources CHANNEL OR EMAIL [email protected]
!!!!
!!!! ONCE YOU HAVE ACCESS, YOU CAN EDIT THIS FILE AT
!!!! https://github.com/Door43/{0}-{1}/blob/master/{2}-{3}/{4}.usfm
!!!!
——————————————————————————————————————

{5}
'''.format(resource, lang, booknum, bk, chp, content)
        print p
        ep.setText(padID=p, text=content.encode('utf-8'))
コード例 #8
0
ファイル: ep_export.py プロジェクト: samuelanthrayose/tools
def main(slug, ver):
    today = ''.join(str(datetime.date.today()).rsplit('-')[0:3])
    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 slug.lower() in x]
    ver_pads.sort()

    if ver.lower() == 'draft':
        outdir = draftout.format(slug.lower(), 'en')
    elif ver.lower() == 'test':
        outdir = testout.format(slug.lower(), 'en')
    else:
        outdir = baseout.format(slug.lower(), 'en')

    books_published = save(ver_pads, outdir, slug, ep, ver)
    status = { "slug": slug.lower(),
               "name": names[slug],
               "lang": "en",
               "date_modified": today,
               "books_published": books_published,
               "status": { "checking_entity": "Wycliffe Associates",
                           "checking_level": "3",
                           "comments": "Original source text",
                           "contributors": "Wycliffe Associates",
                           "publish_date": today,
                           "source_text": "en",
                           "source_text_version": ver,
                           "version": ver
                          }
             }
    writeJSON('{0}/status.json'.format(outdir), status)
    writeFile('{0}/LICENSE.usfm'.format(outdir), LICENSE.format(ver,
                                                    names[slug], basis[slug]))
    print "Check {0} and do a git push".format(outdir)
コード例 #9
0
def main(slug, outdir):
    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 slug.lower() in x]
    ver_pads.sort()

    outdir = outdir.format(slug.lower(), 'en')

    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()
        content = []
        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
            content = httpsre.sub(u'', content)
            content = srre.sub(u'', content)
            content = s1re.sub(u'', content)
            content = s_re.sub(u'', content)
            bookdir = u'{0}/{1}-{2}'.format(outdir, books[bk][1], bk)
            if not os.path.exists(bookdir):
                os.makedirs(bookdir)
            outfile = u'{0}/{1}.usfm'.format(bookdir, chapter)
            writeFile(outfile, u''.join(content))

    print u"\nGenerated files in {0}. Done.".format(outdir)
コード例 #10
0
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))
コード例 #11
0
def main(args):
    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 args.slug.lower() in x]
    ver_pads.sort()
    bk_pads = [x for x in ver_pads if contains_digits(x)]

    for p in bk_pads:
        if p != 'en-en-ulb-gen-01': continue
        # Get text
        p_orig = ep.getText(padID=p)['text']
        p_content = p_orig

        # Run transformations
        if args.hyphenfix:
            p_content = hyphenfixre.sub(u'—', p_content)
            p_content = p_content.replace(u' — ', u'—')
        #if args.versefix:
            #p_content = verseFix(p_content)
        #if args.smartquotes:
            #p_content = smartquotes(p_content)

        # save text
        if p_orig != p_content:
            print 'Updating {0}'.format(p)
            try:
                ep.setText(padID=p, text=p_content.encode('utf-8'))
            except EtherpadException as e:
                print '{0}: {1}'.format(e, p)
        break
コード例 #12
0
def main(slug, outdir):
    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 slug.lower() in x]
    ver_pads.sort()

    outdir = outdir.format(slug.lower(), 'en')

    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()
        content = []
        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
            content = httpsre.sub(u'', content)
            content = srre.sub(u'', content)
            content = s1re.sub(u'', content)
            content = s_re.sub(u'', content)
            bookdir = u'{0}/{1}-{2}'.format(outdir, books[bk][1], bk)
            if not os.path.exists(bookdir):
                os.makedirs(bookdir)
            outfile = u'{0}/{1}.usfm'.format(bookdir, chapter)
            writeFile(outfile, u''.join(content))

    print u"\nGenerated files in {0}. Done.".format(outdir)
コード例 #13
0
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)

    namespace = u'ta-'

    all_pads = ep.listAllPads()
    ver_pads = [x for x in all_pads['padIDs'] if x.startswith(namespace)]
    ver_pads.sort()

    for p in ver_pads:
        content = []
        # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti')
        content = ep.getText(padID=p)['text']
        if 'Welcome to Etherpad!' in content:
            continue
        print u"rewrite /p/" + p + ""
コード例 #14
0
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))
コード例 #15
0
ファイル: ep_export_ta.py プロジェクト: PurpleGuitar/tools
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)

    namespace = u'ta-'

    all_pads = ep.listAllPads()
    ver_pads = [x for x in all_pads['padIDs'] if x.startswith(namespace)]
    ver_pads.sort()

    for p in ver_pads:
        content = []
        # Skips pad that WA uses for communication (e.g. 'en-ulb-1ti')
        content = ep.getText(padID=p)['text']
        if 'Welcome to Etherpad!' in content:
            continue
        print u"rewrite /p/"+p+""
コード例 #16
0
ファイル: ep_recent.py プロジェクト: MissionalDigerati/tools
def writeFile(f, content):
    out = codecs.open(f, encoding="utf-8", mode="w")
    out.write(content)
    out.close()


if __name__ == "__main__":
    try:
        pw = open("/root/.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)
    os.environ["TZ"] = "US/Eastern"
    pads = ep.listAllPads()
    recent = []
    for p in pads["padIDs"]:
        if not p:
            continue
        recent.append((p, ep.getLastEdited(padID=p)["lastEdited"]))

    recent_sorted = sorted(recent, key=lambda p: p[1], reverse=True)
    recent_html = []
    for i in recent_sorted:
        t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(str(i[1])[0:10])))
        recent_html.append(link.format(i[0], t))

    writeFile(path, page_template.format("\n".join(recent_html)))
コード例 #17
0
    out = codecs.open(f, encoding='utf-8', mode='w')
    out.write(content)
    out.close()


if __name__ == '__main__':
    try:
        pw = open('/root/.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)
    os.environ['TZ'] = 'US/Eastern'
    pads = ep.listAllPads()
    recent = []
    for p in pads['padIDs']:
        if not p:
            continue
        recent.append((p, ep.getLastEdited(padID=p)['lastEdited']))

    recent_sorted = sorted(recent, key=lambda p: p[1], reverse=True)
    recent_html = []
    for i in recent_sorted:
        t = time.strftime('%Y-%m-%d %H:%M:%S',
                          time.localtime(int(str(i[1])[0:10])))
        recent_html.append(link.format(i[0], t))

    writeFile(path, page_template.format('\n'.join(recent_html)))
コード例 #18
0
ファイル: export.py プロジェクト: Tamriel/etherpad_txt_export
from etherpad_lite import EtherpadLiteClient
import os
import requests
import click
import ftfy

URL = 'http://yourserver:yourport'
APIKEY = 'inser your key here'

client = EtherpadLiteClient(base_url=URL + '/api',
                            base_params={'apikey': APIKEY},
                            api_version='1.2.9')

os.makedirs('exported_pads', exist_ok=True)

pad_list = client.listAllPads()['padIDs']
with click.progressbar(pad_list) as progress_bar:
    for pad_name in progress_bar:
        with open('exported_pads' + os.sep + pad_name + '.txt', 'w') as file:
            pad_content = ftfy.fix_text(requests.get(URL + '/p/' + pad_name + '/export/txt').text)
            file.write(pad_content)