Beispiel #1
0
def get_page_tree(name):
    def attr_picker(c):
        return {
            "title": c["title"],
        }

    log.info("Load page tree of space '%s'" % name)
    url = f"rest/api/space/{name}/content?depth=root"
    page_tree = get_nested_content(url, attr_picker)
    return page_tree
Beispiel #2
0
def open_gui_browser(url):
    if not url.startswith(BASE_URL):
        if url.startswith('/'):
            url = f"{BASE_URL}{url}"
        else:
            url = f"{BASE_URL}/{url}"

    cmd = config["GuiBrowser"]
    if '%s' not in cmd:
        cmd = cmd + " '%s'"
    cmd = cmd % url
    log.info("Executing: `%s`" % cmd)
    process = Popen(split(cmd), stdin=PIPE, stderr=PIPE)
    process.communicate()
Beispiel #3
0
    def alert(self, message, msgtype='info'):
        """Show a message in the status line

        :message: the alert message as a string
        :msgtype: one of 'info', 'warning', 'error'
        """

        log.info("Alert (%s): %s" % (msgtype, message))
        self.footer.status_line.set_text((msgtype, message))
        try:
            self.loop.draw_screen()
        except AssertionError:
            # If we are outside the loop (which happens after catching an
            # exception) then this would cause another exception and lead to
            # an exit of the program
            pass
Beispiel #4
0
def open_cli_browser(url, app):
    """Opens an URL in a CLI browser"""

    if not url.startswith(BASE_URL):
        if url.startswith('/'):
            url = f"{BASE_URL}{url}"
        else:
            url = f"{BASE_URL}/{url}"

    cmd = config["CliBrowser"]
    if '%s' not in cmd:
        cmd = cmd + " '%s'"
    cmd = cmd % url
    log.info("Executing: `%s`" % cmd)
    app.loop.screen.stop()
    process = Popen(split(cmd), stdin=PIPE, stderr=PIPE)
    process.communicate()
    app.loop.screen.start()
Beispiel #5
0
def get_editor_input(prompt):
    """Open a tempfile with an external editor

    :prompt: Text to be written to the file beforehand
    """

    tfile = tempfile.NamedTemporaryFile('w', delete=False)
    tfile.write(prompt)
    tfile.flush()
    cmd = config["Editor"]
    if '%s' not in cmd:
        cmd += " '%s'"
    cmd = cmd % tfile.name
    log.info("Executing: `%s`" % cmd)
    process = Popen(split(cmd))
    process.communicate()
    with open(tfile.name, 'r') as f:
        content = f.read()
    return content
Beispiel #6
0
    def get_microblog(self):
        """Load Microblog entries via HTTP"""

        log.info("Fetch microblog...")
        response = make_request(
            "rest/microblog/1.0/microposts/search",
            params={
                "offset": self.offset,
                "limit": self.limit,
                "replyLimit": self.replyLimit,
            },
            method='POST',
            data=self.post_data,
            headers={
                "Content-Type": "application/json",
            },
        )
        entries = response.json()
        result = []
        for e in entries['microposts']:
            result.append(MicroblogEntry(MicroblogObject(e), is_reply=False))
        self.offset += len(result)
        return result
Beispiel #7
0
 def update(self, size=None):
     log.info("Update ...")
     self.params["start"] = 0
     self.entries = self.get_entries()
     self.redraw()
Beispiel #8
0
 def load_much_more(self, size=None):
     log.info("Load much more ...")
     self.params["limit"] *= 5
     self.entries += self.get_entries()
     self.params["limit"] //= 5
     self.redraw()
Beispiel #9
0
 def load_more(self, size=None):
     log.info("Load more ...")
     self.entries += self.get_entries()
     self.redraw()