Exemple #1
0
    def setUp(self):
        """
        Creates an application and
        almost launches it.
        """
        # Make whatever config class that application uses only look for our
        # Set up our customised config file
        logFileName = Path('tmp/app data/test.conf')
        sys.argv[0] = 'exe/exe'
        Config._getConfigPathOptions = lambda s: [logFileName]
        if not logFileName.dirname().exists():
            logFileName.dirname().makedirs()
        confParser = ConfigParser()
        self._setupConfigFile(confParser)
        confParser.write(logFileName)
        # Start up the app and friends
        if G.application is None:
            G.application = Application()

        self.app = G.application
        G.application = self.app
        self.app.loadConfiguration()
        self.app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        self.session = FakeSession()
        self.app.webServer.root.bindNewPackage(self.package, self.session)
        self.mainpage = self.app.webServer.root.mainpages[
            self.session.uid]['temp']
        self.mainpage.idevicePane.client = self.client
 def __exportIdevice(self, filename):
     """
     export the current generic idevices.
     """
     if not filename.endswith('.idp'):
         filename = filename + '.idp'
     name = Path(filename).namebase
     package = Package(name)
     package.idevices.append(self.editorPane.idevice.clone())
     package.save(filename)
Exemple #3
0
    def createPackage(self):
        """
        Creates a package
        """
        log.debug(u"createPackage")
        # Make up an initial unique name
        i = 1
        name = u"newPackage"
        while name in self.loaded:
            name = u"newPackage" + unicode(i)
            i += 1
        package = Package(name)
        self.loaded[package.name] = package

        return package
Exemple #4
0
    def setUp(self):
        class MyConfig:
            def __init__(self):
                self.port = 8081
                self.dataDir = Path(".")
                self.webDir = Path(".")
                self.exeDir = Path(".")
                self.configDir = Path(".")
                self.styles = ["default"]

        app = Application()
        app.config = MyConfig()
        app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        app.webServer.root.bindNewPackage(self.package)
        self.outline = app.webServer.root.children['temp'].outlinePane
 def setUp(self):
     """
     Creates an application and 
     almost launches it.
     """
     # Make whatever config class that application uses only look for our
     # Set up our customised config file
     logFileName = Path('tmp/app data/test.conf')
     Config._getConfigPathOptions = lambda s: [logFileName]
     if not logFileName.dirname().exists():
         logFileName.dirname().makedirs()
     confParser = ConfigParser()
     self._setupConfigFile(confParser)
     confParser.write(logFileName)
     # Start up the app and friends
     self.app = Application()
     self.app.loadConfiguration()
     self.app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     self.app.webServer.root.bindNewPackage(self.package)
     self.mainpage = self.app.webServer.root.children['temp']
Exemple #6
0
 def tick2(self, package):
     bkup = Package(package.name)
     bkup = Package('bakcup')
     package.root.copyToPackage(bkup)
     bkup.save(package.name + '.bk')
Exemple #7
0
    def __init__(self, package, clear=True):
        log.info('****** Checking package at %s ******' % package.filename)
        self.package = package
        from exe.engine.package import Package
        self.tmppackage = Package('temp')
        self.inconsistencies = []
        self.nodes = [self.package.root] + list(
            self.package.root.walkDescendants())
        self.clear = clear
        self.idevices = {}
        idevice_ids = []
        duplicated_idevice_ids = []
        log.info('Computing content resource references')
        for node in self.nodes:
            for idevice in node.idevices:
                if idevice.id in idevice_ids:
                    duplicated_idevice_ids.append((idevice, node))
                idevice_ids.append(idevice.id)
                if not idevice.parentNode:
                    log.error(
                        'No parent node for idevice %s in node %s! Fixing...' %
                        (idevice.klass, node.title))
                    idevice.parentNode = node
                if idevice.parentNode != node:
                    log.error(
                        'Parent node of idevice %s in node %s not match! Fixing...'
                        % (idevice.klass, node.title))
                    idevice.parentNode = node
                fields = idevice.getRichTextFields()
                if fields and idevice.klass != 'ImageMagnifierIdevice':
                    for field in fields:
                        if hasattr(field, 'parentNode'):
                            if not field.parentNode:
                                log.error(
                                    'No parent node for field in idevice %s in node %s! Fixing...'
                                    % (idevice.klass, node.title))
                                field.parentNode = node
                            if field.parentNode != node:
                                log.error(
                                    'Parent node of field in idevice %s in node %s not match! Fixing...'
                                    % (idevice.klass, node.title))
                                field.parentNode = node
                        for resource in field.ListActiveResources(
                                field.content_w_resourcePaths):
                            path = self.package.resourceDir / resource
                            if not path.exists():
                                msg = "%s referenced in idevice %s of node %s not exists" % (
                                    resource, idevice.klass, node.title)
                                self.appendInconsistency(
                                    msg, 'contentResourceNonExistant',
                                    self.package, path)
                            else:
                                if path in self.idevices:
                                    self.idevices[path].append(field)
                                else:
                                    self.idevices[path] = [field]
                else:
                    for resource in idevice.userResources:
                        path = self.package.resourceDir / resource.storageName
                        if not path.exists():
                            msg = "%s referenced in idevice %s of node %s not exists" % (
                                resource, idevice.klass, node.title)
                            self.appendInconsistency(
                                msg, 'contentResourceNonExistant',
                                self.package, path)
                        else:
                            if path in self.idevices:
                                self.idevices[path].append(idevice)
                            else:
                                self.idevices[path] = [idevice]

        for idevice, node in duplicated_idevice_ids:
            log.error(
                'Duplicated idevice id %s in node %s of type %s. Fixing...' %
                (idevice.id, node.title, idevice.klass))
            while idevice.id in idevice_ids:
                idevice.id = unicode(int(idevice.id) + 1)
            idevice_ids.append(idevice.id)

        max_idevice_id = 0 if not idevice_ids else max(
            map(lambda x: int(x), idevice_ids))
        if Idevice.nextId <= max_idevice_id:
            log.error('Wrong idevice next id. Fixing...')
            Idevice.nextId = max_idevice_id + 1