Beispiel #1
0
 def check_key_executable(self, key):
     """
     Log the values of the launch agent/daemon keys in self.check_keys_hash
     """
     value = get_plist_key(self.plist_file, key)
     if value:
         try:
             if type(value) in [str, unicode]:
                 # This should only get triggered by the Program key
                 self.data[key.lower()] = str(to_ascii(value))
                 self.data["%s_hash" % key.lower()] = hash_file(
                     str(to_ascii(value))
                 )
             elif type(value) in [list]:
                 # This should only get triggered by the
                 # ProgramArguments key
                 self.data[key.lower()] = encode(" ".join(value))
                 self.data["%s_hash" % key.lower()] = hash_file(
                     str(value[0])
                 )
         except IOError:
             self.data["%s_hash" % key.lower()] = "File DNE"
     else:
         self.data[key.lower()] = "KEY DNE"
         self.data["%s_hash" % key.lower()] = "KEY DNE"
Beispiel #2
0
    def bucket_files(self, files, hashes):
        """
        takes an array of files and a dictionary in {file: hash} form and
        returns data structures indicitive of which files have changed since
        the last execution
        """
        # changed files and new_files are dicts so that we can store the hash
        # when we compute and thus not have to compute it twice
        changed_files = {}
        new_files = {}

        # since the hash of same_files hasn't changed, we don't need to store
        # it past the comparison
        same_files = []

        for fname in files:
            file_hash = hash_file(fname)
            if fname in hashes:
                if hashes[fname] == file_hash:
                    same_files.append(fname)
                else:
                    changed_files[fname] = file_hash
            else:
                new_files[fname] = file_hash

        return changed_files, new_files, same_files
Beispiel #3
0
    def bucket_files(self, files, hashes):
        """
        takes an array of files and a dictionary in {file: hash} form and
        returns data structures indicitive of which files have changed since
        the last execution
        """
        # changed files and new_files are dicts so that we can store the hash
        # when we compute and thus not have to compute it twice
        changed_files = {}
        new_files = {}

        # since the hash of same_files hasn't changed, we don't need to store
        # it past the comparison
        same_files = []

        for fname in files:
            file_hash = hash_file(fname)
            if fname in hashes:
                if hashes[fname] == file_hash:
                    same_files.append(fname)
                else:
                    changed_files[fname] = file_hash
            else:
                new_files[fname] = file_hash

        return changed_files, new_files, same_files
Beispiel #4
0
    def check_key_executable(self, key):
        """
        Log the values of the launch agent/daemon keys in self.check_keys_hash
        """
        key = key.lower()
        key_hash = "%s_hash" % (key.lower(), )

        value = get_plist_key(self.plist_file, key)
        if value:
            try:
                if isinstance(value, basestring):
                    # This should only get triggered by the Program key
                    self.data[key] = str(to_ascii(value))
                    self.data[key_hash] = hash_file(str(to_ascii(value)))
                elif isinstance(value, (list, tuple)):
                    # This should only get triggered by the
                    # ProgramArguments key
                    self.data[key] = encode(" ".join(value))
                    self.data[key_hash] = hash_file(str(value[0]))
            except IOError:
                self.data[key_hash] = "File DNE"
        else:
            self.data[key] = "KEY DNE"
            self.data[key_hash] = "KEY DNE"
Beispiel #5
0
    def check_key_executable(self, key):
        """
        Log the values of the launch agent/daemon keys in self.check_keys_hash
        """
        key = key.lower()
        key_hash = "%s_hash" % (key.lower(), )

        value = get_plist_key(self.plist_file, key)
        if value:
            try:
                if isinstance(value, basestring):
                    # This should only get triggered by the Program key
                    self.data[key] = str(to_ascii(value))
                    self.data[key_hash] = hash_file(str(to_ascii(value)))
                elif isinstance(value, (list, tuple)):
                    # This should only get triggered by the
                    # ProgramArguments key
                    self.data[key] = encode(" ".join(value))
                    self.data[key_hash] = hash_file(str(value[0]))
            except IOError:
                self.data[key_hash] = "File DNE"
        else:
            self.data[key] = "KEY DNE"
            self.data[key_hash] = "KEY DNE"