Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
userdefault.UserDefaultPrinter Class Reference

List of all members.

Public Member Functions

def __init__
def clear
def get
def set
def __repr__

Public Attributes

 lpoptions

Detailed Description

Definition at line 24 of file userdefault.py.


Constructor & Destructor Documentation

Definition at line 25 of file userdefault.py.

00025 
00026     def __init__ (self):
00027         try:
00028             lpoptions = os.environ["HOME"]
00029         except KeyError:
00030             try:
00031                 lpoptions = "/home/" + os.environ["USER"]
00032             except KeyError:
00033                 lpoptions = None
00034 
00035         if lpoptions:
00036             lpoptions += "/.cups/lpoptions"
00037 
00038         self.lpoptions = lpoptions


Member Function Documentation

Definition at line 85 of file userdefault.py.

00085 
00086     def __repr__ (self):
00087         return "<UserDefaultPrinter (%s)>" % repr (self.get ())

Here is the call graph for this function:

Definition at line 39 of file userdefault.py.

00039 
00040     def clear (self):
00041         if not self.lpoptions:
00042             return
00043 
00044         try:
00045             opts = file (self.lpoptions).readlines ()
00046         except IOError:
00047             return
00048 
00049         for i in range (len (opts)):
00050             if opts[i].startswith ("Default "):
00051                 opts[i] = "Dest " + opts[i][8:]
00052         file (self.lpoptions, "w").writelines (opts)

Definition at line 53 of file userdefault.py.

00053 
00054     def get (self):
00055         if not self.lpoptions:
00056             return None
00057 
00058         try:
00059             opts = file (self.lpoptions).readlines ()
00060         except IOError:
00061             return None
00062 
00063         for i in range (len (opts)):
00064             if opts[i].startswith ("Default "):
00065                 rest = opts[i][8:]
00066                 slash = rest.find ("/")
00067                 if slash != -1:
00068                     space = rest[:slash].find (" ")
00069                 else:
00070                     space = rest.find (" ")
00071                 return rest[:space]
00072         return None

Here is the caller graph for this function:

def userdefault.UserDefaultPrinter.set (   self,
  default 
)

Definition at line 73 of file userdefault.py.

00073 
00074     def set (self, default):
00075         p = subprocess.Popen ([ "lpoptions", "-d", default ],
00076                               close_fds=True,
00077                               stdin=file ("/dev/null"),
00078                               stdout=file ("/dev/null", "w"),
00079                               stderr=subprocess.PIPE)
00080         (stdout, stderr) = p.communicate ()
00081         exitcode = p.wait ()
00082         if exitcode != 0:
00083             raise RuntimeError (exitcode, stderr.strip ())
00084         return


Member Data Documentation

Definition at line 37 of file userdefault.py.


The documentation for this class was generated from the following file: