On Wed, Nov 7, 2018 at 11:42 PM srinivasan <srinivasan....@gmail.com> wrote: > > Some I managed to fix temporarily as below, might be useful for others. Also > please correct me if anything wrong or for any improvements in the below > > cmd = "blkid -o export %s" % partition_path > out = self._helper.execute_cmd_output_string(cmd) > var = out.split("TYPE=", 1)[1] > quoted = re.compile('(?<=^\")[^"]*') > for string in quoted.findall(var): > return string
Leaving aside the fact that MS Comic Sans is known to the State of California to cause cancer, this code is probably okay if you don't mind it being overengineered. Here's a much simpler version, albeit untested: out = subprocess.check_output(["blkid", "-o", "export", partition_path]) for line in out.split("\n"): item, value = line.split("=") if item == "TYPE": return value No helper needed. Safe against command injection. Uses the known format of the command's output; if you want other information as well as the type, you could get that too. ChrisA -- https://mail.python.org/mailman/listinfo/python-list