dabo Commit
Revision 5964
Date: 2010-08-27 11:21:09 -0700 (Fri, 27 Aug 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5964

Changed:
U   trunk/dabo/lib/reportUtils.py

Log:
Switched from os.system() and os.popen2() to subprocess.call() 
in previewPDF() and printPDF(). Removes DeprecationWarnings in
Python 2.6 and above.


Diff:
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py       2010-08-26 12:43:04 UTC (rev 5963)
+++ trunk/dabo/lib/reportUtils.py       2010-08-27 18:21:09 UTC (rev 5964)
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
-import datetime
-
-from decimal import Decimal
 import os
 import sys
+import subprocess
 import tempfile
+import datetime
+from decimal import Decimal
 
 
 class TempFileHolder(object):
@@ -40,9 +40,10 @@
 def previewPDF(path, modal=False):
        """Preview the passed PDF file in the default PDF viewer."""
        try:
+               # On Windows, use the default PDF viewer (probably Adobe 
Acrobat)
                os.startfile(path)
        except AttributeError:
-               # startfile only available on Windows
+               # On Mac, use the default PDF viewer (probably Preview.app)
                if sys.platform == "darwin":
                        os.system("open %s" % path)
                else:
@@ -60,11 +61,7 @@
                                        break
 
                        if viewer:
-                               if modal:
-                                       sysfunc = os.system
-                               else:
-                                       sysfunc = os.popen2
-                               sysfunc("%s '%s'" % (viewer, path))
+                               subprocess.call((viewer, path))
 
 
 
@@ -74,7 +71,7 @@
                os.startfile(path, "print")
        except AttributeError:
                # startfile() only available on Windows
-               os.system("lpr %s" % path)
+               subprocess.call(("lpr", path))
 
 
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to