Last active
September 17, 2016 12:19
-
-
Save rickheil/d4fb9b58c3c75505ebf7e2d7d41a27b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""Formats lpoptions output to PrinterGenerator input""" | |
import sys | |
import subprocess | |
def main(): | |
subproc = subprocess.Popen(['lpoptions', '-p', sys.argv[1], '-l'], stdout=subprocess.PIPE) | |
out, err = subproc.communicate() | |
printer_options = out.splitlines(True) | |
options_output = "" | |
for line in printer_options: | |
line = line.split(' ') | |
option_name = line[0].split('/')[0] | |
for option in line: | |
if '*' in option: | |
selected_option = option[1:] | |
options_output += "%s=%s " % (option_name, selected_option) | |
print options_output.replace("\n", "") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment