예제 #1
0
 def preview(self):
     try:
         c = EtherpadLiteClient(base_url=self.get_api_url())
         data = c.getHTML(padID=self.padname)
         return data
     except (HTTPError, URLError):
         return super(Etherpad, self).preview()
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
파일: app.py 프로젝트: cryu/camper
    def finalize_setup(self):
        """do our own configuration stuff"""
        self.config.dbs = AttributeMapper()
        mydb = self.config.dbs.db = pymongo.Connection(
            self.config.mongodb_host,
            self.config.mongodb_port)[self.config.mongodb_name]
        self.config.dbs.barcamps = db.Barcamps(mydb.barcamps,
                                               app=self,
                                               config=self.config)
        self.config.dbs.sessions = db.Sessions(mydb.sessions,
                                               app=self,
                                               config=self.config)
        self.config.dbs.pages = db.Pages(mydb.pages,
                                         app=self,
                                         config=self.config)
        self.config.dbs.session_comments = db.Comments(mydb.session_comments,
                                                       app=self,
                                                       config=self.config)
        self.module_map.uploader.config.assets = Assets(mydb.assets,
                                                        app=self,
                                                        config=self.config)

        # etherpad connection
        self.config.etherpad = EtherpadLiteClient(
            base_params={'apikey': self.config.ep_api_key},
            base_url=self.config.ep_endpoint)
예제 #4
0
 def EtherMap(self):
     epclient = EtherpadLiteClient({'apikey': self.server.apikey},
                                   self.server.apiurl)
     result = epclient.createAuthorIfNotExistsFor(
         authorMapper=self.user.id.__str__(), name=self.__str__())
     self.authorID = result['authorID']
     return result
예제 #5
0
 def client(self):
     if self._client is None:
         self._client = EtherpadLiteClient(
             base_url='%s/api' % self.params['url'],
             api_version='1.2.13',
             base_params={'apikey': self.params['apikey']})
     return self._client
예제 #6
0
def get_etherpad_client():
    """
    Returns an instance of EtherpadLiteClient.
    """
    return EtherpadLiteClient(base_url=settings.ETHERPAD_URL + '/api',
                              api_version='1.2.7',
                              base_params={'apikey': settings.ETHERPAD_KEY})
예제 #7
0
 def __init__(self,
              apikey,
              padID,
              targetFile,
              base_url='http://localhost:9001/api'):
     self._con = EtherpadLiteClient(base_params={'apikey': apikey},
                                    base_url=base_url)
     self._padID = padID
     self._file = targetFile
예제 #8
0
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')
예제 #9
0
def pasteText(padID=None, text=None):
    text = request.args.get('text')
    padID = request.args.get('padID')
    c = EtherpadLiteClient(
        base_params={
            'apikey':
            'f42591e743037bc39d530ba6b1550b0d558aed32f3e9f5e8f12cdeaa1a48b0cd'
        })
    #padList = c.listAllPads()
    #padList['padIDs']['']
    message = c.appendText(padID=padID, text=text)
    return json.dumps(message)
예제 #10
0
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)
예제 #11
0
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)
예제 #12
0
def main():
    c = EtherpadLiteClient(base_params={'apikey': cfg.myapikey},
                           base_url=cfg.mybaseURL)
    plenum = c.getHTML(padID=cfg.mypadID)
    filename = cfg.filePrefix + '_' + str(
        get_last_Plenum().strftime("%Y.%m.%d")).replace('.', '_')
    write_Plenum(filename, plenum)

    # plenumwiki = str(plenum["html"]).replace("<!DOCTYPE HTML><html><body>", "").replace("</body></html>", "") + "[[Kategorie:" + cfg.wikiKategorie + "]]"
    wikiname = cfg.wikiwikiprefix + '_' + str(
        get_last_Plenum().strftime("%Y_%m"))
    addToWiki(wikiname, str(plenum["html"]))

    c.setText(padID=cfg.mypadID,
              text='Plenum ' + str(get_next_Plenum().strftime("%Y.%m.%d")))
예제 #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)

    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'))
예제 #14
0
    def __init__(self,
                 apikey,
                 padID,
                 targetFile,
                 base_url='http://localhost:9001/api',
                 marker=None):
        self._con = EtherpadLiteClient(base_params={'apikey': apikey},
                                       base_url=base_url)
        self._padID = padID
        self._file = targetFile
        if marker == None:
            marker = id_generator(10)
        self._lineMarker = '===== ' + marker + ' ============='

        # Insert line markers at the end of pad
        pad = self._con.getText(padID=self._padID)
        newText = pad['text'] + self._lineMarker + '\n' + self._lineMarker
        self._con.setText(padID=self._padID, text=newText)
예제 #15
0
def user_preferences_updated(sender, instance, *args, **kwargs):
    """This method is executed whenever we get a signal
    that user preferences table had pre_save event which
    signifies an insertion or an update.
    This is a good time to run peer matching.
    """
    user_preference = instance
    peer_preference = random_match(user_preference)

    if peer_preference:
        peer = peer_preference.user_session.user
        user = user_preference.user_session.user
        print("You have been matched with {}".format(peer.username))

        # Create a new peer group for the user and the peer
        pad_group = create_or_get_pad_group(user, peer)

        # Create a new pad for the user and the peer
        pad = Pad(name=get_pad_name(), server=pad_group.server, group=pad_group)
        pad.save()

        # Write a question to the pad
        question = None
        concept = user_preference.concept
        questions = Questions.objects.filter(Q(concepts__name__icontains=concept.name))
        if questions:
            question_index = random.randint(0, questions.count() - 1)
            question = questions[question_index]
        else:
            raise Exception(
            "No questions found in the database for concept {}".format(
                concept.name))

        if question:
            epclient = EtherpadLiteClient({'apikey':pad.server.apikey}, pad.server.apiurl)
            epclient.setText(padID=pad.padid, text=question.description)

         # Mark user and peer in collaborating state
        UserState.objects.filter(user_preference=user_preference).update(state='C')
        UserState.objects.filter(user_preference=peer_preference).update(state='C')

        # Save the pad the users will be using
        UserState.objects.filter(user_preference=user_preference).update(pad=pad)
        UserState.objects.filter(user_preference=peer_preference).update(pad=pad)
예제 #16
0
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)
예제 #17
0
파일: app.py 프로젝트: sk1p/camper
    def finalize_setup(self):
        """do our own configuration stuff"""
        self.config.dbs = AttributeMapper()
        mydb = self.config.dbs.db = pymongo.MongoClient(self.config.mongodb_url)[self.config.mongodb_name]
        self.config.dbs.barcamps = db.Barcamps(mydb.barcamps, app=self, config=self.config)
        self.config.dbs.sessions = db.Sessions(mydb.sessions, app=self, config=self.config)
        self.config.dbs.pages = db.Pages(mydb.pages, app=self, config=self.config)
        self.config.dbs.blog = db.BlogEntries(mydb.blog, app=self, config=self.config)
        self.config.dbs.galleries = db.ImageGalleries(mydb.galleries, app=self, config=self.config)
        self.config.dbs.session_comments = db.Comments(mydb.session_comments, app=self, config=self.config)
        self.config.dbs.participant_data = db.DataForms(mydb.participant_data, app=self, config=self.config)
        self.config.dbs.tickets = db.Tickets(mydb.tickets, app=self, config=self.config)
        self.config.dbs.userfavs = db.UserFavs(mydb.userfavs, app=self, config=self.config)
        self.module_map.uploader.config.assets = Assets(mydb.assets, app=self, config=self.config)

        # etherpad connection
        self.config.etherpad = EtherpadLiteClient(
            base_params={'apikey': self.config.ep_api_key},
            base_url=self.config.ep_endpoint
        )
예제 #18
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)
예제 #19
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
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))
예제 #21
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 + ""
예제 #22
0
def _init_client():
    """Initialises the etherpad lite client"""
    return EtherpadLiteClient(
        base_url=settings.COSINNUS_ETHERPAD_BASE_URL,
        api_version='1.2.7',
        base_params={'apikey': settings.COSINNUS_ETHERPAD_API_KEY})
예제 #23
0
def find(pattern, top):
    # Based off of http://www.dabeaz.com/generators-uk/genfind.py
    for path, dirlist, filelist in os.walk(top):
        for name in fnmatch.filter(filelist, pattern):
            yield os.path.join(path, name)


if __name__ == '__main__':
    if len(sys.argv) > 1:
        book = str(sys.argv[1]).strip()
    else:
        print 'Please specify the book to load.'
        sys.exit(1)
    try:
        pw = open('/root/.ep_api_key', 'r').read().strip()
        ep = EtherpadLiteClient(base_params={'apikey': pw})
    except:
        e = sys.exc_info()[0]
        print 'Problem logging into Etherpad via API: {0}'.format(e)
        sys.exit(1)

    book_notes = '{0}/{1}'.format(notes, book)
    for f in find('*.txt', book_notes):
        if 'questions' in f: continue
        pad_text = codecs.open(f, 'r', encoding='utf-8').read()
        parts = f.split('/')
        pad_name = '-'.join(
            ['en', 'bible', book, parts[-2], parts[-1].replace('.txt', '')])
        try:
            ep.createPad(padID=pad_name, text=pad_text)
            print link.format(pad_name)
예제 #24
0
파일: etherpad.py 프로젝트: cronala/mafiasi
 def __init__(self):
     self.api = EtherpadLiteClient(
         api_version='1.2.1',
         base_url='{0}/api'.format(settings.ETHERPAD_URL),
         base_params={'apikey': settings.ETHERPAD_API_KEY})
예제 #25
0
def etherpad(**kwargs):
    # for key, value in kwargs.items():
    #     print ("%s == %s" %(key, value))
    if (len(kwargs) == 0):
        args = parse_args(sys.argv)
    else:
        args = Namespace(**kwargs)
        if (args.host and args.port and args.user and args.apikey):
            # print("launch etherpad with %s:%s for user %s and key %s" % (str(args.host), args.port, args.user, str(args.apikey)))
            print("launch etherpad")
        else:
            return 1

    URL = "http://" + str(args.host).replace("'",
                                             "") + ":" + args.port + "/api"
    #print("URL ="+URL)
    sys.stdout.flush()

    #time.sleep(2)
    try:
        client = EtherpadLiteClient(
            base_url=URL,
            base_params={"apikey": str(args.apikey).replace("'", "")},
            api_version="1",
            timeout=7000)
    except Exception as err:
        traceback.print_exc(file=sys.stderr)
        print("Error client : %s" % (err))
        sys.exit(1)

    #time.sleep(1)
    padID = passrandom(20)
    DATEcourse = re.sub(
        r'\..*', '',
        datetime.datetime.isoformat(datetime.datetime.now(),
                                    sep='_').replace(":", "-"))
    try:
        if (args.etherpadurl):
            PadURL = args.etherpadurl + padID.decode('utf-8')
        else:
            PadURL = padID.decode('utf-8')
    except:
        PadURL = padID.decode('utf-8')

    MESSAGE = "Subject: [Course " + DATEcourse + "] new padID : " + PadURL + " \nHello \nFor your course at " + DATEcourse + ",please use this PadID to put your (machine, login) :\n" + PadURL
    tf = tempfile.NamedTemporaryFile(mode="w+b",
                                     dir="/tmp",
                                     prefix="",
                                     delete=False)
    tf.write(MESSAGE.encode('utf-8'))
    tf.close()
    print(MESSAGE)
    sys.stdout.flush()
    try:
        if (args.mail):
            COMMAND = '/sbin/sendmail -F "' + args.user + '" -f ' + args.mail + ' -t ' + args.mail + ' < ' + tf.name
            os.system(COMMAND)
    except:
        pass
    try:
        if (args.filestud):
            import csv
            with open(args.filestud, newline='') as csvfile:
                spamreader = csv.reader(csvfile, delimiter=';', quotechar='|')
                for row in spamreader:
                    destination = row[1]
                    COMMAND = '/sbin/sendmail -F "' + args.user + '" -f ' + args.mail + ' -t ' + destination + ' < ' + tf.name
                    os.system(COMMAND)
    except:
        pass

    try:
        myauth = client.createAuthor(name=args.user)
        pad = client.createPad(padID=padID, text=initText)
    except Exception as err:
        traceback.print_exc(file=sys.stderr)
        print("Error create_pad : %s" % (err))
        sys.exit(2)

    # help(pad)

    # COMMAND=URL+"/1/setText?apikey="+str(APIKEY)+"&padID="+str(padID)+"&text='"+initText+"'"
    # os.system("curl "+COMMAND)

    # Wait for students
    print(
        "Wait 60s (or more) for students and teacher must finish by 'END' string."
    )
    time.sleep(60)

    while True:
        try:
            Out = client.getText(padID=padID)
        except Exception as err:
            traceback.print_exc(file=sys.stderr)
            print("Error get_text : %s" % (err))
            sys.exit(2)

        # COMMAND=URL+"/1/getText?apikey="+str(APIKEY)+"&padID="+str(padID)+"&jsonp=?"
        # os.system("curl "+COMMAND)

        # Build node file.
        #print(Out)
        print(Out["text"])
        List = Out["text"].replace(initText, "").split("\n")
        print(List)
        sys.stdout.flush()

        if ("END" in List):
            iEnd = List.index("END")
            List = List[:iEnd]
            break
        else:
            time.sleep(2)

    # Créé le tableau des élèves connectés en direct.
    studfile = "./directconnection.csv"
    with open(studfile, 'w+') as f:
        for stud in List:
            f.write(stud + "\n")
        f.close()
    os.system("ls -la " + studfile)
예제 #26
0
            reply = "I was unable to get anything useful from the page at URL " + page_request + ".  Either the HTML's completely broken, it's not HTML at all, or the URL's bad."
            send_message_to_user(reply)
            time.sleep(float(polling_time))
            continue

        # Clean up the title for later.
        title = title.strip()

        # Take a SHA-1 hash of the article because that seems to be the most
        # reliable way of generating a valid padID for Etherpad-Lite.
        hash.update(title)
        hash.update(body)
        pad_id = hash.hexdigest()

        # Contact Etherpad and create a new pad with the contents of the page.
        etherpad = EtherpadLiteClient(base_params={'apikey': etherpad_api_key},
            api_version=api_version)
        page_text = str(title) + "\n\n" + str(body) + "\n"
        try:
            etherpad.createPad(padID=pad_id, text=page_text)
        except EtherpadException as e:
            logger.warn("Etherpad-Lite module threw an exception: " + str(e))
            send_message_to_user(str(e))
            time.sleep(float(polling_time))
            continue

        # E-mail a success message with a link to the archived page to the
        # bot's user.
        subject_line = "Successfully downloaded page '" + title + "'"
        message = "I have successfully downloaded and parsed the text of the web page '" + title + "'.  You can read the page at the URL " + archive_url + pad_id 
        if not email_response(subject_line, message):
            logger.warn("Unable to e-mail failure notice to the user.")
예제 #27
0
</div></div>
</div>
</body>
</html>'''


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:
예제 #28
0
from etherpad_lite import EtherpadLiteClient

etherpad_client = EtherpadLiteClient(
    base_params={
        "apikey":
        "5da9f78b8445e157e04332920ba299aaa2aa54dc1fd9ab55519c4e5165fb6c88"
    },
    base_url="http://etherpad:9001/api",
)
예제 #29
0
 def epclient(self):
     return EtherpadLiteClient({'apikey': self.server.apikey},
                               self.server.apiurl)
예제 #30
0
def main():
    c = EtherpadLiteClient(base_params={'apikey': cfg.myapikey},
                           base_url=cfg.mybaseURL)
    c.setText(padID=cfg.mypadIDFalse, text=cfg.falsPadText)