[X2Go-Commits] python-x2go.git - build-baikal (branch) updated: 9950236dd6e2246d6e5fb51dd77a0fe339e8cdbb
X2Go dev team
git-admin at x2go.org
Wed Jan 8 15:27:40 CET 2014
The branch, build-baikal has been updated
via 9950236dd6e2246d6e5fb51dd77a0fe339e8cdbb (commit)
from 219a8e705e34b0629102273814e5614ee4005378 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
x2go/printactions.py | 28 ++++++++++++++++------------
x2go/printqueue.py | 21 +++++++++++++++++++--
x2go/x2go_exceptions.py | 5 +++++
3 files changed, 40 insertions(+), 14 deletions(-)
The diff of changes is:
diff --git a/x2go/printactions.py b/x2go/printactions.py
index a9034c3..b273ba6 100644
--- a/x2go/printactions.py
+++ b/x2go/printactions.py
@@ -35,7 +35,7 @@ import shutil
import copy
import types
import threading
-import gevent
+import time
from defaults import X2GOCLIENT_OS as _X2GOCLIENT_OS
if _X2GOCLIENT_OS in ("Windows"):
@@ -180,6 +180,7 @@ class X2goPrintActionPDFVIEW(X2goPrintAction):
)
else:
self.logger('Encountered WindowsError: %s' % str(win_err), loglevel=log.loglevel_ERROR)
+ time.sleep(20)
else:
_hr_filename = self._humanreadable_filename(pdf_file, job_title, spool_dir, )
shutil.copy2(pdf_file, _hr_filename)
@@ -188,8 +189,8 @@ class X2goPrintActionPDFVIEW(X2goPrintAction):
p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=_PRINT_ENV)
# this is nasty!!!!
self.logger('giving PDF viewer 20s to get the PDF file %s loaded' % _hr_filename, loglevel=log.loglevel_DEBUG)
- gevent.sleep(20)
- os.remove(_hr_filename)
+ time.sleep(20)
+ os.remove(_hr_filename)
class X2goPrintActionPDFSAVE(X2goPrintAction):
@@ -236,7 +237,7 @@ class X2goPrintActionPDFSAVE(X2goPrintAction):
shutil.copy2(pdf_file, dest_file)
# this is nasty!!!!
self.logger('copying incomig PDF file %s to %s' % (pdf_file, dest_file) , loglevel=log.loglevel_DEBUG)
- gevent.sleep(20)
+ time.sleep(20)
class X2goPrintActionPRINT(X2goPrintAction):
@@ -276,18 +277,21 @@ class X2goPrintActionPRINT(X2goPrintAction):
"""
_hr_filename = self._humanreadable_filename(pdf_file, job_title, spool_dir)
- shutil.copy2(pdf_file, _hr_filename)
- self.logger('printing incoming PDF file %s' % _hr_filename, loglevel=log.loglevel_NOTICE)
- if sys.platform == 'win32':
+ if _X2GOCLIENT_OS == 'Windows':
+ self.logger('printing incoming PDF file %s' % pdf_file, loglevel=log.loglevel_NOTICE)
win32api.ShellExecute (
0,
"print",
- _hr_filename,
+ pdf_file,
None,
- os.path.dirname(_hr_filename),
+ None,
+ #os.path.dirname(pdf_file),
0,
)
else:
+ _hr_filename = self._humanreadable_filename(pdf_file, job_title, spool_dir)
+ self.logger('printing incoming PDF file %s' % _hr_filename, loglevel=log.loglevel_NOTICE)
+ shutil.copy2(pdf_file, _hr_filename)
if self.printer is None:
cmd_line = [ 'lpr',
'-h',
@@ -307,7 +311,7 @@ class X2goPrintActionPRINT(X2goPrintAction):
p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=_PRINT_ENV)
# this is nasty!!!!
- gevent.sleep(20)
+ time.sleep(20)
class X2goPrintActionPRINTCMD(X2goPrintAction):
@@ -361,7 +365,7 @@ class X2goPrintActionPRINTCMD(X2goPrintAction):
p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=_PRINT_ENV)
# this is nasty!!!!
- gevent.sleep(20)
+ time.sleep(20)
class X2goPrintActionDIALOG(X2goPrintAction):
@@ -413,7 +417,7 @@ class X2goPrintActionDIALOG(X2goPrintAction):
self.client_instance.HOOK_open_print_dialog(_hr_filename,profile_name=self.profile_name, session_name=self.session_name)
# this is nasty!!!!
- gevent.sleep(20)
+ time.sleep(20)
os.remove(_hr_filename)
diff --git a/x2go/printqueue.py b/x2go/printqueue.py
index 1553a87..c0c7a2d 100644
--- a/x2go/printqueue.py
+++ b/x2go/printqueue.py
@@ -39,8 +39,22 @@ import defaults
# we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables)
from backends.printing import X2goClientPrinting as _X2goClientPrinting
+if defaults.X2GOCLIENT_OS != 'Windows':
+ from x2go_exceptions import WindowsError
+
from defaults import X2GO_PRINTING_FILENAME as _X2GO_PRINTING_FILENAME
+def _patiently_remove_file(_dir, _file):
+ _not_removed = True
+ while _not_removed:
+ try:
+ os.remove(os.path.join(_dir, _file))
+ _not_removed = False
+ except WindowsError:
+ # file is probably locked
+ gevent.sleep(5)
+
+
class X2goPrintQueue(threading.Thread):
"""\
If X2go printing is supported in a particaluar L{X2goSession} instance
@@ -231,9 +245,12 @@ def x2go_printjob_handler(job_file=None, pdf_file=None, job_title=None, print_ac
)
logger('removing print job files for %s' % pdf_file, loglevel=log.loglevel_DEBUG)
- os.remove(os.path.join(parent_thread.spool_dir, job_file))
- os.remove(os.path.join(parent_thread.spool_dir, pdf_file))
+ _patiently_remove_file(parent_thread.spool_dir, job_file)
+ logger('removed print job file %s' % job_file, loglevel=log.loglevel_DEBUG)
+ _patiently_remove_file(parent_thread.spool_dir, pdf_file)
+ logger('removed print pdf file %s' % pdf_file, loglevel=log.loglevel_DEBUG)
+
del parent_thread.active_jobs['%s' % pdf_file]
parent_thread.job_history.append(pdf_file)
diff --git a/x2go/x2go_exceptions.py b/x2go/x2go_exceptions.py
index 247c48b..8b7bf97 100644
--- a/x2go/x2go_exceptions.py
+++ b/x2go/x2go_exceptions.py
@@ -27,6 +27,8 @@ __NAME__ = 'x2goexceptions-pylib'
import paramiko
import exceptions
+from defaults import X2GOCLIENT_OS as _X2GOCLIENT_OS
+
# Python X2go Exceptions
AuthenticationException = paramiko.AuthenticationException
"""inherited from Python Paramiko library"""
@@ -55,3 +57,6 @@ class X2goPrintActionException(_X2goException): pass
class X2goSSHProxyException(_X2goException): pass
class X2goSSHProxyAuthenticationException(_X2goException): pass
class X2goNotImplementedYetException(_X2goException): pass
+if _X2GOCLIENT_OS != 'Windows':
+ # faking Windows errors on non-Windows systems...
+ class WindowsError(_X2goException): pass
hooks/post-receive
--
python-x2go.git (Python X2Go Client API)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-x2go.git" (Python X2Go Client API).
More information about the x2go-commits
mailing list