예제 #1
0
    def OnNewFile( self, pathname ):
        try:
            if ( pathname.__class__ == QtCore.QString ):
                pathname = str( pathname )
            print 'OnNewFile: %s' % pathname
            if ( not os.path.exists( pathname ) ):
                logging.debug( 'File doesn\'t exist, skipping' )
                return
            if ( os.path.splitext( pathname )[1] != '.cache' ):
                logging.debug( 'Not a .cache, skipping' )
                return
            try:
                parsed_data = parser.parse( pathname )
            except IOError:
                # I was retrying initially, but some files are deleted before we get a chance to parse them,
                # which is what's really causing this
                traceback.print_exc()
                logging.warning( 'IOError exception, skipping' )
                return
            if ( parsed_data is None ):
                logging.debug( 'No data parsed' )
                return
            t = self.reverence.invtypes.Get( parsed_data[2] )
            
            logging.debug( 'Call %s, regionID %d, typeID %d' % ( parsed_data[0], parsed_data[1], parsed_data[2] ) )

            ret = self.upload_client.send(parsed_data)
            if ( ret ):
                if ( parsed_data[0] == 'GetOldPriceHistory' ):
                    logging.info( 'Uploaded price history for %s in %s' % (t.name, REGION_MAP.get(parsed_data[1], 'Unknown') ) )
                else:
                    logging.info( 'Uploaded orders for %s in %s' % (t.name, REGION_MAP.get(parsed_data[1], 'Unknown') ) )
                logging.debug( 'Removing cache file %s' % pathname )
                os.remove( pathname )
            else:
                logging.error( 'Could not upload file')
                # We should manage some sort of backlog if evemetrics is down
        except:
            traceback.print_exc()
        else:
            print ret
예제 #2
0
    def OnNewFile( self, pathname ):
        try:
            logger.debug('OnNewFile: %s' % pathname)
            if ( os.path.splitext( pathname )[1] != '.cache' ):
                logger.debug( 'Not a .cache, skipping' )
                return True
            try:
                parsed_data = parser.parse( pathname )
            except IOError:
                # I was retrying initially, but some files are deleted before we get a chance to parse them,
                # which is what's really causing this
                logger.debug( 'IOError (cache file deleted), skipping' )
                return True
            if ( parsed_data is None ):
                logger.debug( 'No data parsed' )
                return True
            t = self.reverence.invtypes.Get( parsed_data[2] )
            
            logger.debug( 'Call %s, regionID %d, typeID %d' % ( parsed_data[0], parsed_data[1], parsed_data[2] ) )

            ret = self.upload_client.send(parsed_data)
            if ( ret ):
                if ( parsed_data[0] == 'GetOldPriceHistory' ):
                    logger.info( 'Uploaded price history for %s in %s' % (t.name, REGION_MAP.get(parsed_data[1], 'Unknown') ) )
                else:
                    logger.info( 'Uploaded orders for %s in %s' % (t.name, REGION_MAP.get(parsed_data[1], 'Unknown') ) )
                if self.config.options.delete:
                  logger.debug( 'Removing cache file %s' % pathname )
                  os.remove( pathname )
            else:
                logger.error( 'Could not upload file')
                # We should manage some sort of backlog if evemetrics is down
        except:
            traceback.print_exc()
            logger.exception('Processor Exception')
        else:
          return ret