コード例 #1
0
    def setUp(self):
        # Make/setup self.sRep (with a basePath of tempRepPath)
        # Also set self.__fs to tempRepPath
        if self.recreateFSRep:
            removeTempFSRep()
            createTempFSRep()

        if IceCommon.system.isWindows:
            global tempRepPath
            tempRepPath = tempfile.mkdtemp()

        self.client = pysvn.Client()
        if self.recreateTempRep:
            removeTempRep()
            self.client.checkout(url=tempFSRepUrl + "/TestRep",
                                 path=tempRepPath,
                                 recurse=True)
        iceContext = IceCommon.IceContext
        self.rep = MockRep(IceCommon.FileSystem(tempRepPath))
        iceContext.rep = self.rep
        self.sRep = SvnRep(iceContext,
                           basePath=tempRepPath,
                           svnUrl=tempFSRepUrl + "/TestRep")
        if self.recreateTempRep == False:
            self.revert()
        self.fs = IceCommon.FileSystem(tempRepPath)
 def __init__(self, IceCommon):
     self.fs = IceCommon.FileSystem(".")
     self.system = system
     self.xmlUtils = IceCommon.xmlUtils
     self.rep = MockRep(self.fs)
     self.isWindows = system.isWindows
     self.isLinux = system.isLinux
     self.isMac = system.isMac
コード例 #3
0
def setupRep(fs=None):
    global repUrl
    if fs is None:
        fs = IceCommon.FileSystem(".")
    try:
        fs.delete(testSvnRep)
    except: pass
    try:
        fs.delete(testRep)
    except: pass
    if IceCommon.system.isWindows:
        repUrl = "file:///" + fs.join(fs.absolutePath("."), testSvnRep)
    else:
        repUrl = "file://" + fs.join(fs.absolutePath("."), testSvnRep)
    repUrl += "/testRep"
    fs.unzipToDirectory(testSvnRepZip, testSvnRep)
except:
    import sys, os
    sys.path.append(os.getcwd())
    sys.path.append(".")
    os.chdir("../../")
    from ice_common import IceCommon
    sys.path.append("../utils")
    from system import System, system

#import os
#import sys
#sys.path.append("../ice")
#from ice_common import IceCommon
#from pdf_utils import *

fs = IceCommon.FileSystem(".")

from plugin_pdf_utils import *

basePath = "plugins/pdf_utils/"


class MockIceContext(object):
    def __init__(self, IceCommon):
        self.fs = IceCommon.FileSystem(".")
        self.system = system
        self.xmlUtils = IceCommon.xmlUtils
        self.rep = MockRep(self.fs)
        self.isWindows = system.isWindows
        self.isLinux = system.isLinux
        self.isMac = system.isMac
コード例 #5
0
def main(args, sys, outputWriter):
    shortOptionNames = {
        "h": "help",
        "f": "file",
        "d": "directory",
        "dir": "directory",
        "converter": "convert",
        "v": "verbose",
        "test": "testing"
    }
    flags = [
        "help", "convert", "atompub", "atomconvertpub", "upgrade", "verbose",
        "asserviceonly", "enableexternalaccess", "test", "open"
    ]
    progName = args.pop(0)
    options = IceCommon.getOptions(args, shortOptionNames, flags)
    fs = IceCommon.FileSystem(IceCommon.workingDirectory)
    convert = options.get("convert", False)
    atompub = options.get("atompub", False) or options.get(
        "atomconvertpub", False)
    if convert or atompub:
        file = options.get("file")
        directory = options.get("directory")
        template = options.get("template")
        if file is not None:
            options["file"] = fs.absolutePath(file)
        if directory is not None:
            options["directory"] = fs.absolutePath(directory)
        if template is not None:
            options["template"] = fs.absolutePath(template)

        class OurOutput(object):
            def __init__(self):
                import tempfile
                self.__f = open(tempfile.gettempdir() + "/ice.log", "wb")

            def write(self, data):
                sys.stdout.write(data)
                self.__f.write(data.replace("\n", "\r\n"))

            def close(self):
                self.__f.close()

        output = OurOutput()
        stderr = sys.stderr
        sys.stderr = output
        converterAppMain(progName, options, fs=fs, output=output)
        output.close()
        sys.stderr = stderr
    elif options.get("svn", None) is not None:
        # SVN command
        usageMessage = "Usage: -svn:export -path:UrlOrAbsolutePathToExport -dir:exportToDirectory"
        svnCommand = options.get("svn").lower()
        if options.get("help") is not None:
            outputWriter("%s\n" % usageMessage)
            return (1)
        if svnCommand == "export":
            # from 'path' to 'dir'
            path = options.get("path")
            toDir = options.get("directory")
            if path is None or toDir is None:
                outputWriter("%s\n" % usageMessage)
            else:
                try:
                    outputWriter("Exporting '%s' to '%s'.  Please wait...\n" %
                                 (path, toDir))
                    import pysvn
                    client = pysvn.Client()
                    #path = fs.absolutePath(path)
                    #toDir = fs.absolutePath(toDir)
                    result = client.export(path,
                                           toDir,
                                           force=True,
                                           revision=pysvn.Revision(
                                               pysvn.opt_revision_kind.head),
                                           recurse=True)

                    outputWriter("Exported: %s\n" % str(result))
                    outputWriter("Export completed.\n")
                except Exception, e:
                    outputWriter("Error exporting: %s\n" % str(e))
        else:
            outputWriter("%s\n" % usageMessage)
コード例 #6
0
 def setUp(self):
     self.__fs = IceCommon.FileSystem(".")
     self.htmlToOdt = HtmlToOdt(self.__fs)