Example #1
0
    def signal_processed(self, was_error):
        if self.tmpfile_path is not None:
            os.remove(self.tmpfile_path)

        if self.extracted1_path is not None:
            shutil.rmtree(self.extracted1_path)

        if self.extracted2_path is not None:
            shutil.rmtree(self.extracted2_path)

        log.info("got processed signal")
Example #2
0
    def signal_processed(self, was_error):
        if self.tmpfile_path is not None:
            os.remove(self.tmpfile_path)

        if self.extracted1_path is not None:
            shutil.rmtree(self.extracted1_path)

        if self.extracted2_path is not None:
            shutil.rmtree(self.extracted2_path)

        log.info("got processed signal")
Example #3
0
    def on_startup(cls, config, system_json):
        # TODO: config is not accessible when local
        cls._system = System(config, system_json, service=True)
        cls._config = config
        cls._lock = Lock()

        cls.tmp_dir = config.get('tmp-dir', DEFAULT_TMP_DIR)

        if not os.path.isdir(cls.tmp_dir):
            log.info("Creating tree dir '%s'" % cls.tmp_dir)
            os.mkdir(cls.tmp_dir)
        log.info("Using temporary dir '%s'" % cls.tmp_dir)

        cls.signal_startup(config.get(cls.get_service_name()))
Example #4
0
    def on_startup(cls, config, system_json):
        # TODO: config is not accessible when local
        cls._system = System(config, system_json, service=True)
        cls._config = config
        cls._lock = Lock()

        cls.tmp_dir = config.get('tmp-dir', DEFAULT_TMP_DIR)

        if not os.path.isdir(cls.tmp_dir):
            log.info("Creating tree dir '%s'" % cls.tmp_dir)
            os.mkdir(cls.tmp_dir)
        log.info("Using temporary dir '%s'" % cls.tmp_dir)

        cls.signal_startup(config.get(cls.get_service_name()))
Example #5
0
    def download(self, file_id):
        '''
        Download a file
        @param file_id: a file to be downloaded
        @return: file content
        '''
        # avoid getting files from the local system
        if not file_id.get_service_name() == self.get_service_name():
            raise ValueError("File not from this service")

        filename = os.path.basename(file_id.get_raw()['identifier'])
        file_path = os.path.join(self.upload_dir, filename)

        with self.get_lock():
            log.info("downloading '%s'" % str(file_path))
            with open(file_path, 'rb') as f:
                content = f.read()

        return content
Example #6
0
    def upload(self, blob):
        '''
        Upload file to the system
        @param blob: a file content to be store
        @return: file id
        '''
        res = ServiceResult()
        log.info("uploading")
        h = blob_hash(blob)
        dst = os.path.join(self.upload_dir, h)

        with self.get_lock():
            with open(dst, 'wb') as f:
                f.write(blob)

        creation_time = datetime_parse(time.ctime(os.path.getctime(dst)))
        # TODO: remove, use dircache instead
        valid_until = creation_time + self.file_lifetime

        res.result = FileId.construct(self, dst, h)
        return res
Example #7
0
 def signal_startup(cls, config):
     log.info("got startup signal")
     log.info("config sections: " + dict2json(config))
Example #8
0
 def signal_disconnect(self):
     log.info("got disconnect signal")
Example #9
0
 def signal_process(self):
     self.tmpfile_path = None
     self.extracted1_path = None
     self.extracted2_path = None
     log.info("got process signal")
Example #10
0
 def signal_destruct(self):
     log.info("got destruct signal")
Example #11
0
 def signal_connect(self):
     log.info("got connect signal")
Example #12
0
 def signal_termination(cls):
     log.info("got termination signal")
Example #13
0
 def signal_init(self):
     log.info("got init signal")
Example #14
0
 def signal_init(self):
     log.info("got init signal")
Example #15
0
 def signal_startup(cls, config):
     log.info("got startup signal")
     log.info("config sections: " + dict2json(config))
Example #16
0
 def signal_termination(cls):
     log.info("got termination signal")
Example #17
0
 def signal_destruct(self):
     log.info("got destruct signal")
Example #18
0
 def signal_connect(self):
     log.info("got connect signal")
Example #19
0
 def signal_disconnect(self):
     log.info("got disconnect signal")
Example #20
0
 def signal_process(self):
     self.tmpfile_path = None
     self.extracted1_path = None
     self.extracted2_path = None
     log.info("got process signal")