def _probe_smb (self): if not PYSMB_AVAILABLE: return smbc_auth = BackgroundSmbAuthContext () debug = 0 if get_debugging (): debug = 10 ctx = pysmb.smbc.Context (debug=debug, auth_fn=smbc_auth.callback) entries = [] uri = "smb://%s/" % self.hostname debugprint ("smb: trying") try: while smbc_auth.perform_authentication () > 0: if self.quit: debugprint ("smb: no good") return try: entries = ctx.opendir (uri).getdents () except Exception as e: smbc_auth.failed (e) except RuntimeError as e: (e, s) = e.args if e not in [errno.ENOENT, errno.EACCES, errno.EPERM]: debugprint ("Runtime error: %s" % repr ((e, s))) except: nonfatalException () if self.quit: debugprint ("smb: no good") return for entry in entries: if entry.smbc_type == pysmb.smbc.PRINTER_SHARE: uri = "smb://%s/%s" % (smburi.urlquote (self.hostname), smburi.urlquote (entry.name)) info = "SMB (%s)" % self.hostname self._new_device(uri, info) debugprint ("smb: done")
def _probe_smb(self): if not PYSMB_AVAILABLE: return smbc_auth = BackgroundSmbAuthContext() debug = 0 if get_debugging(): debug = 10 ctx = pysmb.smbc.Context(debug=debug, auth_fn=smbc_auth.callback) entries = [] uri = "smb://%s/" % self.hostname debugprint("smb: trying") try: while smbc_auth.perform_authentication() > 0: if self.quit: debugprint("smb: no good") return try: entries = ctx.opendir(uri).getdents() except Exception as e: smbc_auth.failed(e) except RuntimeError as e: (e, s) = e.args if e not in [errno.ENOENT, errno.EACCES, errno.EPERM]: debugprint("Runtime error: %s" % repr((e, s))) except: nonfatalException() if self.quit: debugprint("smb: no good") return for entry in entries: if entry.smbc_type == pysmb.smbc.PRINTER_SHARE: uri = "smb://%s/%s" % (smburi.urlquote( self.hostname), smburi.urlquote(entry.name)) info = "SMB (%s)" % self.hostname self._new_device(uri, info) debugprint("smb: done")
entries = ctx.opendir (uri).getdents () except Exception, e: smbc_auth.failed (e) except RuntimeError, (e, s): if e not in [errno.ENOENT, errno.EACCES, errno.EPERM]: debugprint ("Runtime error: %s" % repr ((e, s))) except: nonfatalException () if self.quit: debugprint ("smb: no good") return for entry in entries: if entry.smbc_type == pysmb.smbc.PRINTER_SHARE: uri = "smb://%s/%s" % (smburi.urlquote (self.hostname), smburi.urlquote (entry.name)) info = "SMB (%s)" % self.hostname self._new_device(uri, info) debugprint ("smb: done") def _probe_jetdirect (self): port = 9100 #jetdirect sock_address = (self.hostname, port) debugprint ("jetdirect: trying") s = open_socket(self.hostname, port) if not s: debugprint ("jetdirect: %s:%d CLOSED" % sock_address) else: # port is open so assume its a JetDirect device