~vcs-imports/system-config-printer/master

« back to all changes in this revision

Viewing changes to probe_printer.py

  • Committer: Tim Waugh
  • Date: 2014-09-11 11:23:14 UTC
  • Revision ID: git-v1:d7de665ca6ec69b2c268d7eb7e7b351b39fc64e8
More use of subprocess.DEVNULL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
 
273
273
    def _probe_snmp (self):
274
274
        # Run the CUPS SNMP backend, pointing it at the host.
275
 
        null = open ("/dev/null", "r+")
276
275
        try:
277
276
            debugprint ("snmp: trying")
278
277
            p = subprocess.Popen (args=["/usr/lib/cups/backend/snmp",
279
278
                                        self.hostname],
280
279
                                  close_fds=True,
281
 
                                  stdin=null,
 
280
                                  stdin=subprocess.DEVNULL,
282
281
                                  stdout=subprocess.PIPE,
283
 
                                  stderr=null)
 
282
                                  stderr=subprocess.DEVNULL)
284
283
        except OSError as e:
285
284
            debugprint ("snmp: no good")
286
285
            if e == errno.ENOENT:
365
364
                        self._cached_attributes['device-make-and-model'])
366
365
            return
367
366
 
368
 
        null = open ("/dev/null", "r+")
369
367
        try:
370
368
            debugprint ("hplip: trying")
371
369
            p = subprocess.Popen (args=["hp-makeuri", "-c", self.hostname],
372
370
                                  close_fds=True,
373
 
                                  stdin=null,
 
371
                                  stdin=subprocess.DEVNULL,
374
372
                                  stdout=subprocess.PIPE,
375
 
                                  stderr=null)
 
373
                                  stderr=subprocess.DEVNULL)
376
374
        except OSError as e:
377
375
            if e == errno.ENOENT:
378
376
                return