Pārlūkot izejas kodu

Add some python 3 compatibility

oz123 10 gadi atpakaļ
vecāks
revīzija
0fca1f1559
3 mainītis faili ar 9 papildinājumiem un 5 dzēšanām
  1. 1 1
      pwman/__init__.py
  2. 5 1
      pwman/util/config.py
  3. 3 3
      scripts/pwman3

+ 1 - 1
pwman/__init__.py

@@ -21,7 +21,7 @@
 import os
 import pkg_resources
 import argparse
-from util import config
+from pwman.util import config
 import sys
 import re
 import data.factory

+ 5 - 1
pwman/util/config.py

@@ -18,8 +18,12 @@
 #============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
+import sys
 
-from ConfigParser import ConfigParser, ParsingError
+if sys.version_info.major > 2:
+    from configparser import ConfigParser, ParsingError
+else:
+    from ConfigParser import ConfigParser, ParsingError
 import copy
 
 

+ 3 - 3
scripts/pwman3

@@ -64,7 +64,7 @@ def auto_convert():
         shutil.move(dbconvertor.newdb_name, dbconvertor.dbname)
         #6) Start the pwman3 normally if all went ok
         return True
-    except Exception, e:
+    except Exception as e:
         raise e
 
 
@@ -93,13 +93,13 @@ def main(args):
 
     try:
         cli.cmdloop()
-    except KeyboardInterrupt, e:
+    except KeyboardInterrupt as e:
         print(e)
 
     if config.get_value("Global", "save") == "True":
         try:
             config.save(args.cfile)
-        except Exception, e:
+        except Exception as e:
             print ("Error: %s" % e)
             sys.exit(-1)