Exception handling advise needed for samba-tool

Andrew Bartlett abartlet at samba.org
Mon Apr 8 17:18:00 MDT 2013


Jelmer,

I'm trying to make the exceptions from samba-tool domain classicupgrade
less intimidating, so I tried this:

diff --git a/python/samba/netcmd/domain.py
b/python/samba/netcmd/domain.py
index 4ba305c..c47b7be 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -1313,9 +1313,12 @@ class cmd_domain_classicupgrade(Command):
         s3conf.load(smbconf)
         samba3 = Samba3(smbconf, s3conf)
 
-        logger.info("Provisioning")
-        upgrade_from_samba3(samba3, logger, targetdir,
session_info=system_session(),
-                            useeadb=eadb, dns_backend=dns_backend,
use_ntvfs=use_ntvfs)
+        logger.info("Preparing to Upgrade")
+        try:
+            upgrade_from_samba3(samba3, logger, targetdir,
session_info=system_session(),
+                                useeadb=eadb, dns_backend=dns_backend,
use_ntvfs=use_ntvfs)
+        except ProvisioningError, e:
+            raise CommandError("Upgrade failed: ", e)
 
 
But I still get:

ERROR(<class 'samba.provision.ProvisioningError'>): Upgrade failed:  -
ProvisioningError: Could not open '/tmp/secrets.tdb', the Samba3 secrets
database: [Errno 2] No such file or directory.  Perhaps you specified
the incorrect smb.conf, --testparm or --dbdir option?
  File "bin/python/samba/netcmd/domain.py", line 1319, in run
    useeadb=eadb, dns_backend=dns_backend, use_ntvfs=use_ntvfs)
  File "bin/python/samba/upgrade.py", line 575, in upgrade_from_samba3
    raise ProvisioningError("Could not open '%s', the Samba3 secrets
database: %s.  Perhaps you specified the incorrect smb.conf, --testparm
or --dbdir option?" % (samba3.privatedir_path("secrets.tdb"), str(e)))

Can you remind me of the correct syntax to turn that into just:

Upgrade failed: Could not open '/tmp/secrets.tdb', the Samba3 secrets
database: [Errno 2] No such file or directory.  Perhaps you specified
the incorrect smb.conf, --testparm or --dbdir option?

Thanks,

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org




More information about the samba-technical mailing list