[gnome-schedule] use os.environ for setting and unsetting POSIXLY_CORRECT



commit bf76fd9a8b7eed15830b2315c71f3d492581b20e
Author: Gaute Hope <eg gaute vetsj com>
Date:   Mon Mar 3 22:11:42 2014 +0100

    use os.environ for setting and unsetting POSIXLY_CORRECT
    
    os.putenv() and os.unsetenv() are not guaranteed to work, neither
    does os.environ seem to be, but it appears to be safer.

 src/examples/dump.py         |    4 ++--
 src/gnome-schedule-export.py |    2 +-
 src/gnome-schedule-import.py |    2 +-
 src/gnome-schedule.py        |    2 +-
 src/mainWindow.py            |    6 ++++--
 src/scheduleapplet.py        |    2 +-
 src/xwrapper.py              |    6 +++---
 7 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/examples/dump.py b/src/examples/dump.py
index 12f1c43..c445b3b 100755
--- a/src/examples/dump.py
+++ b/src/examples/dump.py
@@ -1,4 +1,4 @@
-# dump.py - This just dumps crontab tasks with their info to stdout 
+# dump.py - This just dumps crontab tasks with their info to stdout
 # Copyright (C) 2010  Gaute Hope <eg at gaute dot vetsj dot com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -38,7 +38,7 @@ gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ["POSIXLY_CORRECT"] = "enabled"
     manual_poscorrect = True
 
 uid = os.geteuid ()
diff --git a/src/gnome-schedule-export.py b/src/gnome-schedule-export.py
index 5181411..1c9e1c8 100755
--- a/src/gnome-schedule-export.py
+++ b/src/gnome-schedule-export.py
@@ -39,7 +39,7 @@ gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ["POSIXLY_CORRECT"] = "enabled"
     manual_poscorrect = True
 
 sys.stderr.write(_("Gnome Schedule: Export tasks") + "\n")
diff --git a/src/gnome-schedule-import.py b/src/gnome-schedule-import.py
index 69de337..103b8e0 100755
--- a/src/gnome-schedule-import.py
+++ b/src/gnome-schedule-import.py
@@ -39,7 +39,7 @@ gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ["POSIXLY_CORRECT"] = "enabled"
     manual_poscorrect = True
 
 
diff --git a/src/gnome-schedule.py b/src/gnome-schedule.py
index f265500..2f5c722 100644
--- a/src/gnome-schedule.py
+++ b/src/gnome-schedule.py
@@ -36,7 +36,7 @@ gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ['POSIXLY_CORRECT'] = 'enabled'
     manual_poscorrect = True
 
 if __name__ == "__main__":
diff --git a/src/mainWindow.py b/src/mainWindow.py
index 86cf160..c6a4116 100644
--- a/src/mainWindow.py
+++ b/src/mainWindow.py
@@ -714,7 +714,8 @@ class main:
             os.chmod (path, stat.S_IEXEC | stat.S_IREAD)
 
             # unset POSIXLY_CORRECT if manually set, bug 612459
-            if self.manual_poscorrect: os.unsetenv ('POSIXLY_CORRECT')
+            if self.manual_poscorrect:
+              del os.environ['POSIXLY_CORRECT']
 
             # get terminal and exec params
             terminal = None
@@ -740,7 +741,8 @@ class main:
             tex = terminal.strip () + ' ' + terminalparam.strip () + ' ' + execute
             subprocess.Popen(tex, cwd = self.user_home_dir, shell=True)
 
-            if self.manual_poscorrect: os.putenv ('POSIXLY_CORRECT', 'enabled')
+            if self.manual_poscorrect:
+              os.environ['POSIXLY_CORRECT'] = 'enabled'
 
 
         except Exception, ex:
diff --git a/src/scheduleapplet.py b/src/scheduleapplet.py
index 66700b4..9e4f4c1 100755
--- a/src/scheduleapplet.py
+++ b/src/scheduleapplet.py
@@ -28,7 +28,7 @@ import mainWindow
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ["POSIXLY_CORRECT"] = "enabled"
     manual_poscorrect = True
 
 ##
diff --git a/src/xwrapper.py b/src/xwrapper.py
index db56a08..647f8eb 100755
--- a/src/xwrapper.py
+++ b/src/xwrapper.py
@@ -34,8 +34,8 @@ gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
 
 def check_X (display, xauth):
     # Checking if I can use X
-    os.putenv ('DISPLAY', display)
-    os.putenv ('XAUTHORITY', xauth)
+    os.environ['DISPLAY'] = display
+    os.environ['XAUTHORITY'] = xauth
 
     try:
         import pygtk
@@ -64,7 +64,7 @@ def check_X (display, xauth):
 poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
 manual_poscorrect = False
 if poscorrect_isset == False:
-    os.putenv ("POSIXLY_CORRECT", "enabled")
+    os.environ["POSIXLY_CORRECT"] = "enabled"
     manual_poscorrect = True
 
 if (len (sys.argv) < 2):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]