示例#1
0
    def _openFile(self):
        self.closed = False

        if os.path.exists(self.path):
            self._file = file(self.path, "r+", 1)
            self._file.seek(0, 2)
        else:
            config = utilities.optionReader()
            if self.defaultMode is not None:
                # Set the lowest permissions
                oldUmask = os.umask(0o777)
                try:
                    self._file = file(self.path, "w+", 1)
                    # write header information
                    self._file.write(",".join(map(str, config.getLoggerHeader())))
                finally:
                    os.umask(oldUmask)
            else:
                self._file = file(self.path, "w+", 1)
                # write header information
                self._file.write(",".join(map(str, config.getLoggerHeader())))

        if self.defaultMode is not None:
            try:
                os.chmod(self.path, self.defaultMode)
            except OSError:
                # Probably /dev/null or something?
                pass

        self.lastDate = self.toDate(os.stat(self.path)[8])
示例#2
0
    def _openFile(self):
        self.closed = False

        if os.path.exists(self.path):
            self._file = file(self.path, "r+", 1)
            self._file.seek(0, 2)
        else:
            config = utilities.optionReader()
            if self.defaultMode is not None:
                # Set the lowest permissions
                oldUmask = os.umask(0o777)
                try:
                    self._file = file(self.path, "w+", 1)
                    #write header information
                    self._file.write(','.join(
                        map(str, config.getLoggerHeader())))
                finally:
                    os.umask(oldUmask)
            else:
                self._file = file(self.path, "w+", 1)
                #write header information
                self._file.write(','.join(map(str, config.getLoggerHeader())))

        if self.defaultMode is not None:
            try:
                os.chmod(self.path, self.defaultMode)
            except OSError:
                # Probably /dev/null or something?
                pass

        self.lastDate = self.toDate(os.stat(self.path)[8])
示例#3
0
    def __init__(self, logger, ftpEndpoint, mtrimSerial):
        ''' Initializes our custom protocol

        :param logger: The local file to store results
        :param ftpEndpoint: The endpoint to send results to and read recipes from
        '''
        SerialClientProtocol.__init__(self)
        self.logger = logger
        self.ftpEndpoint = ftpEndpoint
        self.mtrimSerial = mtrimSerial
        self.logFile = logger.getFileName()
        self.ENQCount = 0
        self.lcOEE = LoopingCall(self.startOEEData)
        self.lcAlarms = LoopingCall(self.startAlarmsData)
        self.lcFTP = LoopingCall(self.startFTPTransfer)
        self._reconnecting = False
        self.config = utilities.optionReader()
        fLogFile = logfile.LogFile('df1comms.log', '/home/pi/projects/newSLC/logs', maxRotatedFiles=2)
        fLogObserver = log.FileLogObserver(fLogFile)
        log.startLogging(logfile.LogFile('df1comms.log', '/home/pi/projects/newSLC/logs', maxRotatedFiles=2))
        #log.startLogging(sys.stdout)
        self.notified = False
        self.transferred = False
        self.loaded = False
示例#4
0
def main():
    serialLog.debug("Initializing the client")

    config = utilities.optionReader()

    localDir, remoteDir = config.getFTPDirectories()
    oeeLog = LoggingLineWriter(localDir)
    
    # Create the FTP client
    FTPhost, FTPport = config.getFTPparms()
    ftpEndpoint = TCP4ClientEndpoint(reactor, FTPhost, FTPport)

    #Create MTrim serial connection
    framer = AsciiFramer(MTrimClientDecoder())
    mtrimfactory = MTrimFactory(framer)
    RS422port, RS422baud = config.getRS422parms()    
    mtrim = SerialMTrimClient(mtrimfactory, RS422port, reactor, baudrate = RS422baud)
    
    factory = DF1Factory(oeeLog, ftpEndpoint, mtrim.protocol)
    RS232port, RS232baud = config.getRS232parms()    
    SerialDF1Client(factory, RS232port, reactor, baudrate = RS232baud)

    serialLog.debug("Starting the client")
    reactor.run()