コード例 #1
0
 def _importClass(self, className):
     classloader = ZClassLoader()
     classObj = classloader.loadClass(className)
     if not (issubclass(classObj, IZCustomLogOutput)):
         raise ValueError, _extstr(
             u"logoutput.ClassMustExtendIZCustomLogOutputError"
         ) % className  #$NON-NLS-1$
     return classObj
コード例 #2
0
ファイル: logger.py プロジェクト: mpm2050/Raven
 def shutdown(self):
     self.done = True
     self.debug(
         u"", -1, None,
         _extstr(u"logger.ShuttingDownLogger"))  #$NON-NLS-1$ #$NON-NLS-2$
     while self.running:
         pass
コード例 #3
0
ファイル: schematypes.py プロジェクト: mpm2050/Raven
    def _initFromString(self, dtString):
        m = DATE_TIME_PATTERN.match(dtString)
        if not m:
            raise ZException(
                _extstr(u"schematypes.FailedToParseDateTimeString") %
                dtString)  #$NON-NLS-1$

        year = m.group(2)
        month = m.group(3)
        day = m.group(4)
        hour = m.group(5)
        minute = m.group(6)
        second = m.group(7)

        isUTC = (not m.group(10)) or (m.group(10) == u"Z")  #$NON-NLS-1$
        tz = UTC_TIMEZONE
        if not isUTC:
            tzDir = m.group(12)
            tzHr = m.group(13)
            tzMin = m.group(14)
            tz = ZSimpleTimeZone(tzHr, tzMin, tzDir)

        # Note: not sure about the millis param...
        self._initFromYYYYMMDDHHMMSS(int(year), int(month), int(day),
                                     int(hour), int(minute), int(second), tz)
コード例 #4
0
ファイル: sysprops.py プロジェクト: Tidosho/zoundryraven
 def saveProperties(self):
     try:
         tempSysPropsFileName = self.sysPropsFileName + u".t" #$NON-NLS-1$
         self.sysPropsDoc.save(tempSysPropsFileName, True)
         deleteFile(self.sysPropsFileName)
         renameFile(tempSysPropsFileName, self.sysPropsFileName)
     except Exception, e:
         raise ZException(_extstr(u"sysprops.ErrorSavingPropsFile") % self.sysPropsFileName, e) #$NON-NLS-1$
コード例 #5
0
ファイル: zthread.py プロジェクト: Tidosho/zoundryraven
 def run(self):
     self.done = False
     try:
         if self.runnable:
             self.runnable.run()
         else:
             self._run()
     except Exception, e:
         self._handleException(ZException(_extstr(u"zthread.UnexpectedErrorInThread"), e)) #$NON-NLS-1$
コード例 #6
0
ファイル: command.py プロジェクト: Tidosho/zoundryraven
 def doCommand(self):
     u"""Sequentially invokes doCommand on each of the commands in the collection.""" #$NON-NLS-1$
     for command in self.getCommands():
         if not self.isCancelled():
             try:
                 command.doCommand()
             except Exception, e:
                 self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInDoCommand"), e)) #$NON-NLS-1$
             except:
                 self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInDoCommand"))) #$NON-NLS-1$
コード例 #7
0
ファイル: sysprops.py プロジェクト: mpm2050/Raven
 def saveProperties(self):
     try:
         tempSysPropsFileName = self.sysPropsFileName + u".t"  #$NON-NLS-1$
         self.sysPropsDoc.save(tempSysPropsFileName, True)
         deleteFile(self.sysPropsFileName)
         renameFile(tempSysPropsFileName, self.sysPropsFileName)
     except Exception, e:
         raise ZException(
             _extstr(u"sysprops.ErrorSavingPropsFile") %
             self.sysPropsFileName, e)  #$NON-NLS-1$
コード例 #8
0
ファイル: fileutil.py プロジェクト: Tidosho/zoundryraven
def deleteFile(path):
    # If the path does not exist, just return.
    if not os.path.exists(path):
        return

    # If the path exists but is not a file, that's an error.
    if not os.path.isfile(path):
        raise ZException(_extstr(u"fileutil.InvalidFilePath") % path) #$NON-NLS-1$

    os.remove(path)
コード例 #9
0
ファイル: fileutil.py プロジェクト: mpm2050/Raven
def deleteDirectory(path, alsoDeleteDir=True, deleteFilter=EVERYTHING_FILTER):
    u"""deleteDirectory(string, boolean?) -> None
    Recursively deletes the contents of the given directory.  If the
    alsoDeleteDir boolean flag is True, then the directory itself
    is also deleted.  If it is False, then only the contents of the
    directory are deleted.""" #$NON-NLS-1$

    # If the path doesn't exist, just return 0.
    if not os.path.exists(path):
        return 0

    # Throw if the root path is given as the param!
    if path == u"/" or path.endswith(u":/") or path.endswith(
            u":\\"):  #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$
        raise ZException(
            _extstr(u"fileutil.FailedToDeleteRootPathMsg"))  #$NON-NLS-1$

    # If the path exists, but is not a directory, that's an error.
    if not os.path.isdir(path):
        raise ZException(_extstr(u"fileutil.InvalidDirPath") %
                         path)  #$NON-NLS-1$

    try:
        count = 0
        files = os.listdir(path)
        for file in files:
            fullFile = os.path.join(path, file)
            if os.path.isfile(fullFile):
                if deleteFilter(fullFile):
                    deleteFile(fullFile)
                    count = count + 1
            else:
                shouldDeleteDir = deleteFilter(fullFile)
                count = count + deleteDirectory(fullFile, shouldDeleteDir,
                                                deleteFilter)

        if alsoDeleteDir:
            os.rmdir(path)
        return count
    except Exception, e:
        raise ZException(_extstr(u"fileutil.DirDeleteFailed") % path,
                         e)  #$NON-NLS-1$
コード例 #10
0
ファイル: fileutil.py プロジェクト: mpm2050/Raven
def deleteFile(path):
    # If the path does not exist, just return.
    if not os.path.exists(path):
        return

    # If the path exists but is not a file, that's an error.
    if not os.path.isfile(path):
        raise ZException(_extstr(u"fileutil.InvalidFilePath") %
                         path)  #$NON-NLS-1$

    os.remove(path)
コード例 #11
0
ファイル: zthread.py プロジェクト: mpm2050/Raven
 def run(self):
     self.done = False
     try:
         if self.runnable:
             self.runnable.run()
         else:
             self._run()
     except Exception, e:
         self._handleException(
             ZException(_extstr(u"zthread.UnexpectedErrorInThread"),
                        e))  #$NON-NLS-1$
コード例 #12
0
ファイル: command.py プロジェクト: Tidosho/zoundryraven
 def undoCommand(self):
     u"""Sequentially (in reverse order) invokes undoCommand on each of the commands in the collection.""" #$NON-NLS-1$
     cmdList = []
     cmdList.extend( self.getCommands() )
     cmdList.reverse()
     for command in cmdList:
         try:
             command.undoCommand()
         except Exception, e:
             self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInUnDoCommand"), e)) #$NON-NLS-1$
         except:
コード例 #13
0
ファイル: command.py プロジェクト: mpm2050/Raven
 def doCommand(self):
     u"""Sequentially invokes doCommand on each of the commands in the collection."""  #$NON-NLS-1$
     for command in self.getCommands():
         if not self.isCancelled():
             try:
                 command.doCommand()
             except Exception, e:
                 self._handleException(
                     ZException(
                         _extstr(u"zcommand.UnexpectedErrorInDoCommand"),
                         e))  #$NON-NLS-1$
             except:
                 self._handleException(
コード例 #14
0
ファイル: schematypes.py プロジェクト: Tidosho/zoundryraven
    def __init__(self, date = None):
        param = date
        if not date:
            param = getCurrentUtcDateTime()

        if isinstance(param, str) or isinstance(param, unicode):
            self._initFromString(param)
        elif isinstance(param, long) or isinstance(param, int):
            self._initFromLongMs(param)
        elif isinstance(param, datetime):
            self.dateTime = convertToUtcDateTime(param)
        else:
            raise ZException(_extstr(u"schematypes.SchemaDateTimeFormatError")) #$NON-NLS-1$
コード例 #15
0
ファイル: schematypes.py プロジェクト: mpm2050/Raven
    def __init__(self, date=None):
        param = date
        if not date:
            param = getCurrentUtcDateTime()

        if isinstance(param, str) or isinstance(param, unicode):
            self._initFromString(param)
        elif isinstance(param, long) or isinstance(param, int):
            self._initFromLongMs(param)
        elif isinstance(param, datetime):
            self.dateTime = convertToUtcDateTime(param)
        else:
            raise ZException(_extstr(
                u"schematypes.SchemaDateTimeFormatError"))  #$NON-NLS-1$
コード例 #16
0
ファイル: command.py プロジェクト: mpm2050/Raven
 def undoCommand(self):
     u"""Sequentially (in reverse order) invokes undoCommand on each of the commands in the collection."""  #$NON-NLS-1$
     cmdList = []
     cmdList.extend(self.getCommands())
     cmdList.reverse()
     for command in cmdList:
         try:
             command.undoCommand()
         except Exception, e:
             self._handleException(
                 ZException(
                     _extstr(u"zcommand.UnexpectedErrorInUnDoCommand"),
                     e))  #$NON-NLS-1$
         except:
コード例 #17
0
ファイル: fileutil.py プロジェクト: Tidosho/zoundryraven
def deleteDirectory(path, alsoDeleteDir = True, deleteFilter = EVERYTHING_FILTER):
    u"""deleteDirectory(string, boolean?) -> None
    Recursively deletes the contents of the given directory.  If the
    alsoDeleteDir boolean flag is True, then the directory itself
    is also deleted.  If it is False, then only the contents of the
    directory are deleted.""" #$NON-NLS-1$

    # If the path doesn't exist, just return 0.
    if not os.path.exists(path):
        return 0

    # Throw if the root path is given as the param!
    if path == u"/" or path.endswith(u":/") or path.endswith(u":\\"): #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$
        raise ZException(_extstr(u"fileutil.FailedToDeleteRootPathMsg")) #$NON-NLS-1$

    # If the path exists, but is not a directory, that's an error.
    if not os.path.isdir(path):
        raise ZException(_extstr(u"fileutil.InvalidDirPath") % path) #$NON-NLS-1$

    try:
        count = 0
        files = os.listdir(path)
        for file in files:
            fullFile = os.path.join(path, file)
            if os.path.isfile(fullFile):
                if deleteFilter(fullFile):
                    deleteFile(fullFile)
                    count = count + 1
            else:
                shouldDeleteDir = deleteFilter(fullFile)
                count = count + deleteDirectory(fullFile, shouldDeleteDir, deleteFilter)

        if alsoDeleteDir:
            os.rmdir(path)
        return count
    except Exception, e:
        raise ZException(_extstr(u"fileutil.DirDeleteFailed") % path, e) #$NON-NLS-1$
コード例 #18
0
ファイル: fileutil.py プロジェクト: Tidosho/zoundryraven
def getFileMetaData(fileName):
    u"""getFileMetaData(string) -> (string, string, int, ZSchemaDateTime)
    Called to get meta information about a file.  Pass in the file
    name and get back a tuple of information:  (shortFileName, abs
    file name, file size, timestamp).""" #$NON-NLS-1$

    if not os.path.isfile(fileName):
        raise ZException(_extstr(u"fileutil.NotAValidFileError") % fileName) #$NON-NLS-1$
    shortName = os.path.basename(fileName)
    absPath = os.path.abspath(fileName)
    status = os.lstat(absPath)
    size = status[stat.ST_SIZE]
    modEpoch = status[stat.ST_MTIME]
    modifiedTimeDT = getDateTimeFromEpoch(modEpoch)
    return (shortName, absPath, size, ZSchemaDateTime(modifiedTimeDT))
コード例 #19
0
ファイル: fileutil.py プロジェクト: mpm2050/Raven
def getFileMetaData(fileName):
    u"""getFileMetaData(string) -> (string, string, int, ZSchemaDateTime)
    Called to get meta information about a file.  Pass in the file
    name and get back a tuple of information:  (shortFileName, abs
    file name, file size, timestamp).""" #$NON-NLS-1$

    if not os.path.isfile(fileName):
        raise ZException(_extstr(u"fileutil.NotAValidFileError") %
                         fileName)  #$NON-NLS-1$
    shortName = os.path.basename(fileName)
    absPath = os.path.abspath(fileName)
    status = os.lstat(absPath)
    size = status[stat.ST_SIZE]
    modEpoch = status[stat.ST_MTIME]
    modifiedTimeDT = getDateTimeFromEpoch(modEpoch)
    return (shortName, absPath, size, ZSchemaDateTime(modifiedTimeDT))
コード例 #20
0
ファイル: command.py プロジェクト: mpm2050/Raven
class ZCommandGroup(ZCommandBase):
    u"""Encapsulates a group of commands."""  #$NON-NLS-1$

    def __init__(self, command=None, name=None):
        ZCommandBase.__init__(self, name)
        self.commands = []
        self.addCommand(command)

    def addCommand(self, command):
        u"""addCommand(IZCommand) -> void
        Adds the given command to internal collection.""" #$NON-NLS-1$
        if command and command != self and command not in self.commands:
            self.commands.append(command)

    def getCommands(self):
        u"""getCommands() -> list of IZCommand objects
        Returns list of commands.""" #$NON-NLS-1$
        return self.commands

    def cancel(self):
        u"""Flags all commands in the collection as cancelled."""  #$NON-NLS-1$
        for command in self.getCommands():
            command.cancel()
        ZCommandBase.cancel(self)

    def doCommand(self):
        u"""Sequentially invokes doCommand on each of the commands in the collection."""  #$NON-NLS-1$
        for command in self.getCommands():
            if not self.isCancelled():
                try:
                    command.doCommand()
                except Exception, e:
                    self._handleException(
                        ZException(
                            _extstr(u"zcommand.UnexpectedErrorInDoCommand"),
                            e))  #$NON-NLS-1$
                except:
                    self._handleException(
                        ZException(
                            _extstr(u"zcommand.UnexpectedErrorInDoCommand"))
                    )  #$NON-NLS-1$
コード例 #21
0
ファイル: schematypes.py プロジェクト: Tidosho/zoundryraven
    def _initFromString(self, dtString):
        m = DATE_TIME_PATTERN.match(dtString)
        if not m:
            raise ZException(_extstr(u"schematypes.FailedToParseDateTimeString") % dtString) #$NON-NLS-1$

        year = m.group(2);
        month = m.group(3);
        day = m.group(4);
        hour = m.group(5);
        minute = m.group(6);
        second = m.group(7);

        isUTC = (not m.group(10)) or (m.group(10) == u"Z") #$NON-NLS-1$
        tz = UTC_TIMEZONE
        if not isUTC:
            tzDir = m.group(12)
            tzHr = m.group(13)
            tzMin = m.group(14)
            tz = ZSimpleTimeZone(tzHr, tzMin, tzDir)

        # Note: not sure about the millis param...
        self._initFromYYYYMMDDHHMMSS(int(year), int(month), int(day), int(hour), int(minute), int(second), tz)
コード例 #22
0
ファイル: zthread.py プロジェクト: mpm2050/Raven
    def run(self):
        self.done = False
        try:
            if self.runnable:
                self.runnable.run()
            else:
                self._run()
        except Exception, e:
            self._handleException(
                ZException(_extstr(u"zthread.UnexpectedErrorInThread"),
                           e))  #$NON-NLS-1$
        except:
            self._handleException(
                ZException(
                    _extstr(u"zthread.UnexpectedErrorInThread")))  #$NON-NLS-1$
        self.done = True

    # end run()

    def _handleException(self, zexception):  #@UnusedVariable
        zexception.printStackTrace()

    # end _handleException()

    def _run(self):
        pass

    # end _run()

    def isDone(self):
コード例 #23
0
ファイル: fileutil.py プロジェクト: mpm2050/Raven
def checkDirectory(dirPath):
    if not os.path.isdir(dirPath):
        raise ZException(_extstr(u"fileutil.InvalidDirPath") %
                         dirPath)  #$NON-NLS-1$
コード例 #24
0
ファイル: fileutil.py プロジェクト: mpm2050/Raven
def checkFile(fileName):
    if not os.path.isfile(fileName):
        raise ZException(_extstr(u"fileutil.InvalidFilePath") %
                         fileName)  #$NON-NLS-1$
コード例 #25
0
ファイル: logoutput.py プロジェクト: Tidosho/zoundryraven
 def _importClass(self, className):
     classloader = ZClassLoader()
     classObj = classloader.loadClass(className)
     if not (issubclass(classObj, IZCustomLogOutput)):
         raise ValueError, _extstr(u"logoutput.ClassMustExtendIZCustomLogOutputError") % className #$NON-NLS-1$
     return classObj
コード例 #26
0
ファイル: zthread.py プロジェクト: Tidosho/zoundryraven
            name = u"ZThread" #$NON-NLS-1$
        Thread.__init__(self, None, None, name)
        self.setDaemon(daemonic)
    # end __init__()

    def run(self):
        self.done = False
        try:
            if self.runnable:
                self.runnable.run()
            else:
                self._run()
        except Exception, e:
            self._handleException(ZException(_extstr(u"zthread.UnexpectedErrorInThread"), e)) #$NON-NLS-1$
        except:
            self._handleException(ZException(_extstr(u"zthread.UnexpectedErrorInThread"))) #$NON-NLS-1$
        self.done = True
    # end run()

    def _handleException(self, zexception): #@UnusedVariable
        zexception.printStackTrace()
    # end _handleException()

    def _run(self):
        pass
    # end _run()

    def isDone(self):
        return self.done
    # end isDone()
コード例 #27
0
ファイル: fileutil.py プロジェクト: Tidosho/zoundryraven
def checkFile(fileName):
    if not os.path.isfile(fileName):
        raise ZException(_extstr(u"fileutil.InvalidFilePath") % fileName) #$NON-NLS-1$
コード例 #28
0
ファイル: fileutil.py プロジェクト: Tidosho/zoundryraven
def checkDirectory(dirPath):
    if not os.path.isdir(dirPath):
        raise ZException(_extstr(u"fileutil.InvalidDirPath") % dirPath) #$NON-NLS-1$
コード例 #29
0
ファイル: command.py プロジェクト: mpm2050/Raven
        u"""Sequentially (in reverse order) invokes undoCommand on each of the commands in the collection."""  #$NON-NLS-1$
        cmdList = []
        cmdList.extend(self.getCommands())
        cmdList.reverse()
        for command in cmdList:
            try:
                command.undoCommand()
            except Exception, e:
                self._handleException(
                    ZException(
                        _extstr(u"zcommand.UnexpectedErrorInUnDoCommand"),
                        e))  #$NON-NLS-1$
            except:
                self._handleException(
                    ZException(
                        _extstr(u"zcommand.UnexpectedErrorInUnDoCommand"))
                )  #$NON-NLS-1$


# ----------------------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------------------
class ZAsyncCommand(ZThread, IZCommand):
    u"""Command which executes the given command on a daemon thread."""  #$NON-NLS-1$

    def __init__(self, command):
        self.command = command
        self.running = False
        name = command.getName() + u"_ZAsyncCommand"  #$NON-NLS-1$
        ZThread.__init__(self, name=name, daemonic=True)
コード例 #30
0
ファイル: logger.py プロジェクト: Tidosho/zoundryraven
 def shutdown(self):
     self.done = True
     self.debug(u"", -1, None, _extstr(u"logger.ShuttingDownLogger")) #$NON-NLS-1$ #$NON-NLS-2$
     while self.running:
         pass
コード例 #31
0
ファイル: command.py プロジェクト: Tidosho/zoundryraven
                    self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInDoCommand"), e)) #$NON-NLS-1$
                except:
                    self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInDoCommand"))) #$NON-NLS-1$

    def undoCommand(self):
        u"""Sequentially (in reverse order) invokes undoCommand on each of the commands in the collection.""" #$NON-NLS-1$
        cmdList = []
        cmdList.extend( self.getCommands() )
        cmdList.reverse()
        for command in cmdList:
            try:
                command.undoCommand()
            except Exception, e:
                self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInUnDoCommand"), e)) #$NON-NLS-1$
            except:
                self._handleException(ZException(_extstr(u"zcommand.UnexpectedErrorInUnDoCommand"))) #$NON-NLS-1$

# ----------------------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------------------
class ZAsyncCommand(ZThread, IZCommand):
    u"""Command which executes the given command on a daemon thread.""" #$NON-NLS-1$

    def __init__(self, command):
        self.command = command
        self.running = False
        name = command.getName() +  u"_ZAsyncCommand" #$NON-NLS-1$
        ZThread.__init__(self, name = name, daemonic = True)
    # end __init__()

    def isRunning(self):