Completed
Push — master ( d9d5a0...c9ec26 )
by Philippe
28s
created

Command._zip_file()   A

Complexity

Conditions 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
1
"""Command object
2
3
.. Authors:
4
    Philippe Dessauw
5
    [email protected]
6
7
.. Sponsor:
8
    Alden Dima
9
    [email protected]
10
    Information Systems Group
11
    Software and Systems Division
12
    Information Technology Laboratory
13
    National Institute of Standards and Technology
14
    http://www.nist.gov/itl/ssd/is
15
"""
16
from apputils.fileop import zip_directory, unzip_directory
17
from pipeline.files import FileManager
18
19
20
class Command(object):
21
    """Main command object
22
    """
23
24
    def __init__(self, filename, logger, app_config):
25
        self.logger = logger
26
27
        # ip = app_config["machines"]["master"][0].split('@')
28
        # master_ip = ip[-1:][0]
29
        # master_queue_port = app_config["redis"]["port"]
30
        # self.fman = FileManager(master_ip, master_queue_port)
31
32
        self.filename = filename
33
        # self.unzipped = None
34
        self.unzipped = filename
35
        self.config = app_config
36
37
    # def get_file(self):
38
    #     """Retrieve file from redis and unzip it to the local filesystem
39
    #     """
40
    #     # Get hash from redis
41
    #     self.logger.debug("Retrieving "+self.filename+"...")
42
    #     self.fman.retrieve_file(self.filename)
43
    #
44
    #     # Write it in the tmp folder
45
    #     self._unzip_file()
46
47
    # def store_file(self):
48
    #     """Zip file on the local filesystem and store it to redis
49
    #     """
50
    #     self._zip_file()
51
    #
52
    #     # Store it in redis
53
    #     self.fman.store_file(self.filename)
54
55
    # def _zip_file(self):
56
    #     """Check if the file can be zipped and zip it
57
    #     """
58
    #     if self.unzipped is None:
59
    #         self.logger.error("Zipped directory has not been unzipped")
60
    #         return
61
    #
62
    #     zip_directory(self.unzipped)
63
    #     self.unzipped = None
64
65
    # def _unzip_file(self):
66
    #     """Check if the file can be unzipped and unzip it
67
    #     """
68
    #     if self.unzipped is not None:
69
    #         self.logger.error("Archive already unzipped")
70
    #         return
71
    #
72
    #     self.unzipped = unzip_directory(self.filename)
73