def export_neglected_file_list(monitoring_dir, ROOT_DIR, LOG_DIR, backup_file_list):
    today_obj = datetime.datetime.today()
    today_str = str(today_obj.year)+str(today_obj.month)+str(today_obj.day)
    export_name = today_str + "_neglected_files.log"
    export_path = fs.join([ROOT_DIR, LOG_DIR, export_name])
    if not fs.exists(fs.join([ROOT_DIR, LOG_DIR])):
        try:
            fs.mkdir(fs.join([ROOT_DIR, LOG_DIR]))
        except:
            print ("Can't create LOG_DIR in Func:", export_neglected_file_list)
    try:
        fs.touch(export_path)
        file = fs.open(export_path, 'w')
        for f in backup_file_list:
            try:
                file.write('================================================')
                file.write('\n')
                file.write(fs.filename(f))
                file.write('\n')
                file.write(fs.dirname(f))
                file.write('\n')
            except:
                print("Cant' write export file in func: export_neglected_file_list")
    except:
        print ("cant export in func: export_neglected_file_list")
Beispiel #2
0
def test_touch_on_existing_file():

    before_time = time.ctime(os.path.getmtime(TEST_FILE))

    fs.touch(TEST_FILE)
    after_time = time.ctime(os.path.getmtime(TEST_FILE))

    assert after_time >= before_time
Beispiel #3
0
def test_touch_on_directory():

    before_time = time.ctime(os.path.getmtime(TEST_DIR))

    fs.touch(TEST_DIR)
    after_time = time.ctime(os.path.getmtime(TEST_DIR))

    assert after_time >= before_time
Beispiel #4
0
def test_addpath():
    TEST_MODULE = 'test_foo_bar.py'

    fs.touch(fs.join(TEST_DIR, TEST_MODULE))

    with pytest.raises(ImportError):
        import test_foo_bar

    fs.addpath(TEST_DIR)
    import test_foo_bar
Beispiel #5
0
def test_touch_on_new_file():

    new_file = os.path.join(TEST_DIR, "new_file.txt")

    if (os.path.exists(new_file)):
        raise ValueError("File new_file.txt already exists!")

    fs.touch(new_file)

    assert os.path.exists(new_file) is True
Beispiel #6
0
  def _yum_call(self):
    yum_conf = self.yum_conf.config_file

    if not os.path.exists(yum_conf):
      logger.info("%s doesn't exist, creating one", yum_conf)
      fs.touch(yum_conf, text = self.yum_conf.text())

    opts = [self.yum, '-c', yum_conf, '--installroot', self.chroot, '-y']

    if self.interactive:
      opts.extend(['-e', '1', '-d', '2'])
    else:
      opts.extend(['-e', '1', '-d', '1'])

    return opts
Beispiel #7
0
    def _yum_call(self):
        yum_conf = self.yum_conf.config_file

        if not os.path.exists(yum_conf):
            logger.info("%s doesn't exist, creating one", yum_conf)
            fs.touch(yum_conf, text=self.yum_conf.text())

        opts = [self.yum, '-c', yum_conf, '--installroot', self.chroot, '-y']

        if self.interactive:
            opts.extend(['-e', '1', '-d', '2'])
        else:
            opts.extend(['-e', '1', '-d', '1'])

        return opts
Beispiel #8
0
    def _yum_call(self):
        yum_conf = self.yum_conf.config_file

        if not os.path.exists(yum_conf):
            logger.info("%s doesn't exist, creating one", yum_conf)
            fs.touch(yum_conf, text=self.yum_conf.text())

        opts = [self.yum, "-c", yum_conf, "--installroot", self.chroot, "-y"]

        if self.interactive:
            opts.extend(["-e", "1", "-d", "2"])
        else:
            opts.extend(["-e", "1", "-d", "1"])

        return opts
Beispiel #9
0
 def add_key(self, path, pretend = False):
   if pretend:
     self.pretend_has_keys = True
   else:
     fs.touch(self.gpg_keys)
     open(self.gpg_keys, 'a').write(open(path).read())
Beispiel #10
0
 def add_key(self, path, pretend=False):
     if pretend:
         self.pretend_has_keys = True
     else:
         fs.touch(self.gpg_keys)
         open(self.gpg_keys, 'a').write(open(path).read())