def _command_splitter(self, string): """ Split a command string into list using shlex. """ x_str = string if not is_python3(): x_str = convert_to_rawstring(x_str) return [convert_to_unicode(y) for y in shlex.split(x_str)]
def md5sum(filepath): """ Calcuate md5 hash of given file path. """ import hashlib m = hashlib.md5() readfile = open(filepath, "rb") block = readfile.read(1024) while block: m.update(convert_to_rawstring(block)) block = readfile.read(1024) readfile.close() return m.hexdigest()