Esempio n. 1
0
    def __init__(self):
        junopipename = "juno_%u" % os.getpid()
        junosocket = juno.socketName(junopipename)

        common.unlink(junosocket)

        self.tempdir = tempfile.mkdtemp()

        self.proc = subprocess.Popen(
            ("/usr/bin/soffice",
             "--accept=pipe,name=%s;urp;StarOffice.ServiceManager" %
             junopipename, "--headless",
             "-env:UserInstallation=%s" % juno.mkpath(self.tempdir)),
            stderr=open("/dev/null", "w"),
            preexec_fn=os.setpgrp,
            close_fds=True)

        if not self.waitConnect(junosocket, 30):
            os.killpg(self.proc.pid, signal.SIGKILL)
            raise Exception(
                "soffice socket not found after 30 seconds, giving up")

        l_ctx = uno.getComponentContext()
        res = l_ctx.ServiceManager.createInstance(
            "com.sun.star.bridge.UnoUrlResolver")
        ctx = res.resolve("uno:pipe,name=%s;urp;StarOffice.ComponentContext" %
                          junopipename)
        self.smgr = ctx.ServiceManager
        self.desktop = self.createInstance("com.sun.star.frame.Desktop")
        self.disableCairo()
Esempio n. 2
0
    def __init__(self):
        junopipename = "juno_%u" % os.getpid()
        junosocket = juno.socketName(junopipename)

        common.unlink(junosocket)

        self.tempdir = tempfile.mkdtemp()

        self.proc = subprocess.Popen(("/usr/bin/soffice",
                                      "--accept=pipe,name=%s;urp;StarOffice.ServiceManager" % junopipename,
                                      "--headless",
                                      "-env:UserInstallation=%s" % juno.mkpath(self.tempdir)),
                                     stderr = open("/dev/null", "w"),
                                     preexec_fn = os.setpgrp,
                                     close_fds = True)

        if not self.waitConnect(junosocket, 30):
            os.killpg(self.proc.pid, signal.SIGKILL)
            raise Exception("soffice socket not found after 30 seconds, giving up")
      
        l_ctx = uno.getComponentContext()
        res = l_ctx.ServiceManager.createInstance("com.sun.star.bridge.UnoUrlResolver")
        ctx = res.resolve("uno:pipe,name=%s;urp;StarOffice.ComponentContext" % junopipename)
        self.smgr = ctx.ServiceManager
        self.desktop = self.createInstance("com.sun.star.frame.Desktop")
        self.disableCairo()
Esempio n. 3
0
    def createschema(self):
        self.close()
        common.unlink(self.name)
        self.connect()

        sql = [ """
            CREATE TABLE presos (path TEXT PRIMARY KEY NOT NULL,
                                 mtime INTEGER NOT NULL);
                """, """
            CREATE TABLE slides (preso TEXT NOT NULL REFERENCES presos
                                   ON UPDATE CASCADE ON DELETE CASCADE,
                                 slide INTEGER NOT NULL,
                                 checksum TEXT NOT NULL,
                                 UNIQUE (preso, slide));
                """, """
            CREATE VIRTUAL TABLE slides_fts USING fts4 (content);
                """, """
            CREATE TRIGGER t_slides_fts_del AFTER DELETE ON slides
              BEGIN
                DELETE FROM slides_fts WHERE docid = old.rowid;
              END;
                """, """
            CREATE TRIGGER t_slides_fts_up AFTER UPDATE ON slides
              BEGIN
                UPDATE slides_fts SET docid = new.rowid WHERE docid = old.rowid;
              END;
                """ ]

        for s in map(lambda x: textwrap.dedent(x).strip(), sql):
            self.execute(s)

        self.commit()
Esempio n. 4
0
def del_preso(db, srcp, dstp):
    log("Removing %s..." % srcp)

    doqueries(db, [["DELETE FROM presos WHERE path = ?", [(dstp, )]]])

    common.unlink(os.path.join(config["juno-base"], "root", dstp))
    common.rmtree(os.path.join(config["juno-base"], "slides", dstp))
    common.rmtree(os.path.join(config["juno-base"], "thumbs", dstp))
Esempio n. 5
0
def del_preso(db, srcp, dstp):
    log("Removing %s..." % srcp)

    doqueries(db, [["DELETE FROM presos WHERE path = ?", [(dstp, )]]])

    common.unlink(os.path.join(config["juno-base"], "root", dstp))
    common.rmtree(os.path.join(config["juno-base"], "slides", dstp))
    common.rmtree(os.path.join(config["juno-base"], "thumbs", dstp))
Esempio n. 6
0
    def createschema(self):
        self.close()
        common.unlink(self.name)
        self.connect()

        sql = [
            """
            CREATE TABLE presos (path TEXT PRIMARY KEY NOT NULL,
                                 dirname TEXT NOT NULL,
                                 filename TEXT NOT NULL,
                                 presomtime INTEGER NOT NULL,
                                 filemtime INTEGER NOT NULL,
                                 slides INTEGER NOT NULL)
                """, """
            CREATE TABLE slides (preso TEXT NOT NULL REFERENCES presos
                                   ON UPDATE CASCADE ON DELETE CASCADE,
                                 slide INTEGER NOT NULL,
                                 checksum TEXT NOT NULL,
                                 UNIQUE (preso, slide))
                """, """
            CREATE VIRTUAL TABLE slides_fts USING fts4 (content)
                """, """
            CREATE TRIGGER t_slides_fts_del AFTER DELETE ON slides
              BEGIN
                DELETE FROM slides_fts WHERE docid = old.rowid;
              END
                """, """
            CREATE TRIGGER t_slides_fts_up AFTER UPDATE ON slides
              BEGIN
                UPDATE slides_fts SET docid = new.rowid WHERE docid = old.rowid;
              END
                """
        ]

        for s in map(lambda x: textwrap.dedent(x).strip(), sql):
            self.execute(s)

        self.commit()