Package: virtaal / 0.7.1+git20191021+ds1-2

python-commands.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- a/virtaal/support/openmailto.py
+++ b/virtaal/support/openmailto.py
@@ -136,9 +136,8 @@
 # Platform support for Unix
 else:
 
-    import commands
-    # @WARNING: use the private API of the webbrowser module (._iscommand)
-    import webbrowser
+    import subprocess
+    import shutil
 
     class KfmClient(Controller):
         '''Controller for the KDE kfmclient program.'''
@@ -150,7 +149,7 @@
         def detect_kde_version(self):
             kde_version = None
             try:
-                info = commands.getoutput('kde-config --version')
+                info = subprocess.getoutput('kde-config --version')
 
                 for line in info.splitlines():
                     if line.startswith('KDE'):
@@ -183,7 +182,7 @@
             desktop_environment = 'gnome'
         else:
             try:
-                info = commands.getoutput('xprop -root _DT_SAVE_MODE')
+                info = subprocess.getoutput('xprop -root _DT_SAVE_MODE')
                 if ' = "xfce4"' in info:
                     desktop_environment = 'xfce'
             except (OSError, RuntimeError):
@@ -193,11 +192,11 @@
 
 
     def register_X_controllers():
-        if webbrowser._iscommand('kfmclient'):
+        if shutil.which('kfmclient'):
             _controllers['kde-open'] = KfmClient()
 
         for command in ('gnome-open', 'exo-open', 'xdg-open'):
-            if webbrowser._iscommand(command):
+            if shutil.which(command):
                 _controllers[command] = Controller(command)
 
     def get():
@@ -214,9 +213,10 @@
             return _controllers[controller_name].open
 
         except KeyError:
-            if _controllers.has_key('xdg-open'):
+            if 'xdg-open' in _controllers:
                 return _controllers['xdg-open'].open
             else:
+                import webbrowser
                 return webbrowser.open
 
 
@@ -264,7 +264,7 @@
     kwargs = _fix_addersses(**kwargs)
     parts = []
     for headername in ('to', 'cc', 'bcc', 'subject', 'body', 'attach'):
-        if kwargs.has_key(headername):
+        if headername in kwargs:
             headervalue = kwargs[headername]
             if not headervalue:
                 continue