[Python-modules-commits] [parallax] 01/08: Import parallax_1.0.3.orig.tar.gz
Valentin Vidic
vvidic-guest at moszumanska.debian.org
Tue Nov 28 08:39:55 UTC 2017
This is an automated email from the git hooks/post-receive script.
vvidic-guest pushed a commit to branch master
in repository parallax.
commit 15ecea8d24389474b2f488522e66800ec06c1e4a
Author: Valentin Vidic <Valentin.Vidic at CARNet.hr>
Date: Tue Nov 28 07:55:17 2017 +0100
Import parallax_1.0.3.orig.tar.gz
---
PKG-INFO | 3 ++-
parallax.egg-info/PKG-INFO | 3 ++-
parallax/__init__.py | 22 ++++++++++++++++-----
parallax/askpass_client.py | 26 ++++++++++++++-----------
parallax/askpass_server.py | 1 +
parallax/color.py | 48 +++++++++++++++++++++++++++++++++++++---------
parallax/manager.py | 11 ++++-------
parallax/task.py | 8 +++-----
parallax/version.py | 2 +-
9 files changed, 84 insertions(+), 40 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index b45ff60..6e489f3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,11 +1,12 @@
Metadata-Version: 1.1
Name: parallax
-Version: 1.0.2
+Version: 1.0.3
Summary: Execute commands and copy files over SSH to multiple machines at once
Home-page: https://github.com/krig/parallax/
Author: Kristoffer Gronlund
Author-email: krig at koru.se
License: BSD
+Description-Content-Type: UNKNOWN
Description: Parallax SSH provides an interface to executing commands on multiple
nodes at once using SSH. It also provides commands for sending and receiving files to
multiple nodes using SCP.
diff --git a/parallax.egg-info/PKG-INFO b/parallax.egg-info/PKG-INFO
index b45ff60..6e489f3 100644
--- a/parallax.egg-info/PKG-INFO
+++ b/parallax.egg-info/PKG-INFO
@@ -1,11 +1,12 @@
Metadata-Version: 1.1
Name: parallax
-Version: 1.0.2
+Version: 1.0.3
Summary: Execute commands and copy files over SSH to multiple machines at once
Home-page: https://github.com/krig/parallax/
Author: Kristoffer Gronlund
Author-email: krig at koru.se
License: BSD
+Description-Content-Type: UNKNOWN
Description: Parallax SSH provides an interface to executing commands on multiple
nodes at once using SSH. It also provides commands for sending and receiving files to
multiple nodes using SCP.
diff --git a/parallax/__init__.py b/parallax/__init__.py
index d4c368c..bdedbc8 100644
--- a/parallax/__init__.py
+++ b/parallax/__init__.py
@@ -41,6 +41,19 @@ except NameError:
basestring = str
+def to_ascii(s):
+ """Convert the bytes string to a ASCII string
+ Usefull to remove accent (diacritics)"""
+ if s is None:
+ return s
+ if isinstance(s, str):
+ return s
+ try:
+ return str(s, 'utf-8')
+ except UnicodeDecodeError:
+ return s
+
+
class Error(BaseException):
"""
Returned instead of a result for a host
@@ -48,13 +61,14 @@ class Error(BaseException):
that host.
"""
def __init__(self, msg, task):
+ super().__init__(self)
self.msg = msg
self.task = task
def __str__(self):
if self.task and self.task.errorbuffer:
return "%s, Error output: %s" % (self.msg,
- self.task.errorbuffer)
+ to_ascii(self.task.errorbuffer))
return self.msg
@@ -98,8 +112,7 @@ def _expand_host_port_user(lst):
return (v[0], None, None)
elif len(v) == 2:
return (v[0], v[1], None)
- else:
- return v
+ return v
return [expand(x) for x in lst]
@@ -268,8 +281,7 @@ class _SlurpOutputBuilder(object):
ret[task.host] = (task.exitstatus,
task.outputbuffer or manager.outdir,
task.errorbuffer or manager.errdir,
- self.localdirs.get(task.host, None)
-)
+ self.localdirs.get(task.host, None))
return ret
diff --git a/parallax/askpass_client.py b/parallax/askpass_client.py
index 365e142..44b2c3a 100644
--- a/parallax/askpass_client.py
+++ b/parallax/askpass_client.py
@@ -25,14 +25,15 @@ import textwrap
bin_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
askpass_bin_path = os.path.join(bin_dir, 'parallax-askpass')
ASKPASS_PATHS = (askpass_bin_path,
- '/usr/bin/parallax-askpass',
- '/usr/libexec/parallax/parallax-askpass',
- '/usr/local/libexec/parallax/parallax-askpass',
- '/usr/lib/parallax/parallax-askpass',
- '/usr/local/lib/parallax/parallax-askpass')
+ '/usr/bin/parallax-askpass',
+ '/usr/libexec/parallax/parallax-askpass',
+ '/usr/local/libexec/parallax/parallax-askpass',
+ '/usr/lib/parallax/parallax-askpass',
+ '/usr/local/lib/parallax/parallax-askpass')
_executable_path = None
+
def executable_path():
"""Determines the value to use for SSH_ASKPASS.
@@ -46,12 +47,14 @@ def executable_path():
break
else:
_executable_path = ''
- sys.stderr.write(textwrap.fill("Warning: could not find an"
- " executable path for askpass because Parallax SSH was not"
- " installed correctly. Password prompts will not work."))
+ sys.stderr.write(
+ textwrap.fill("Warning: could not find an"
+ " executable path for askpass because Parallax SSH was not"
+ " installed correctly. Password prompts will not work."))
sys.stderr.write('\n')
return _executable_path
+
def askpass_main():
"""Connects to parallax over the socket specified at PARALLAX_ASKPASS_SOCKET."""
@@ -74,9 +77,10 @@ def askpass_main():
address = os.getenv('PARALLAX_ASKPASS_SOCKET')
if not address:
- sys.stderr.write(textwrap.fill("parallax error: SSH requested a password."
- " Please create SSH keys or use the -A option to provide a"
- " password."))
+ sys.stderr.write(
+ textwrap.fill("parallax error: SSH requested a password."
+ " Please create SSH keys or use the -A option to provide a"
+ " password."))
sys.stderr.write('\n')
sys.exit(1)
diff --git a/parallax/askpass_server.py b/parallax/askpass_server.py
index a75a995..6240a13 100644
--- a/parallax/askpass_server.py
+++ b/parallax/askpass_server.py
@@ -24,6 +24,7 @@ class PasswordServer(object):
self.address = None
self.socketmap = {}
self.buffermap = {}
+ self.password = ""
def start(self, iomap, backlog):
"""Prompts for the password, creates a socket, and starts listening.
diff --git a/parallax/color.py b/parallax/color.py
index adcdbda..cd63356 100644
--- a/parallax/color.py
+++ b/parallax/color.py
@@ -1,27 +1,57 @@
# Copyright (c) 2009-2012, Andrew McNabb
# Copyright (c) 2003-2008, Brent N. Chun
+
def with_color(string, fg, bg=49):
'''Given foreground/background ANSI color codes, return a string that,
when printed, will format the supplied string using the supplied colors.
'''
return "\x1b[%dm\x1b[%dm%s\x1b[39m\x1b[49m" % (fg, bg, string)
+
def B(string):
'''Returns a string that, when printed, will display the supplied string
in ANSI bold.
'''
return "\x1b[1m%s\x1b[22m" % string
-def r(string): return with_color(string, 31) # Red
-def g(string): return with_color(string, 32) # Green
-def y(string): return with_color(string, 33) # Yellow
-def b(string): return with_color(string, 34) # Blue
-def m(string): return with_color(string, 35) # Magenta
-def c(string): return with_color(string, 36) # Cyan
-def w(string): return with_color(string, 37) # White
-#following from Python cookbook, #475186
+def r(string):
+ "Red"
+ return with_color(string, 31)
+
+
+def g(string):
+ "Green"
+ return with_color(string, 32)
+
+
+def y(string):
+ "Yellow"
+ return with_color(string, 33)
+
+
+def b(string):
+ "Blue"
+ return with_color(string, 34)
+
+
+def m(string):
+ "Magenta"
+ return with_color(string, 35)
+
+
+def c(string):
+ "Cyan"
+ return with_color(string, 36)
+
+
+def w(string):
+ "White"
+ return with_color(string, 37)
+
+
+# following from Python cookbook, #475186
def has_colors(stream):
'''Returns boolean indicating whether or not the supplied stream supports
ANSI color.
@@ -29,7 +59,7 @@ def has_colors(stream):
if not hasattr(stream, "isatty"):
return False
if not stream.isatty():
- return False # auto color only on TTYs
+ return False # auto color only on TTYs
try:
import curses
curses.setupterm()
diff --git a/parallax/manager.py b/parallax/manager.py
index 153a369..0fd9ff6 100644
--- a/parallax/manager.py
+++ b/parallax/manager.py
@@ -179,7 +179,7 @@ class Manager(object):
Due to http://bugs.python.org/issue1068268, signals must be masked
when this method is called.
"""
- while 0 < len(self.tasks) and len(self.running) < self.limit:
+ while self.tasks and len(self.running) < self.limit:
task = self.tasks.pop(0)
self.running.append(task)
task.start(self.taskcount, self.iomap, writer, self.askpass_socket)
@@ -217,8 +217,7 @@ class Manager(object):
if min_timeleft is None:
return 0
- else:
- return max(0, min_timeleft)
+ return max(0, min_timeleft)
def interrupted(self):
"""Cleans up after a keyboard interrupt."""
@@ -306,7 +305,7 @@ class IOMap(object):
errno, message = e.args
if errno != EINTR:
sys.stderr.write('Fatal error reading from wakeup pipe: %s\n'
- % message)
+ % message)
raise FatalError
@@ -365,8 +364,7 @@ def make_iomap():
"""
if hasattr(select, 'poll'):
return PollIOMap()
- else:
- return IOMap()
+ return IOMap()
class Writer(threading.Thread):
@@ -442,4 +440,3 @@ class Writer(threading.Thread):
def signal_quit(self):
"""Called from another thread to request the Writer to quit."""
self.queue.put((self.ABORT, None))
-
diff --git a/parallax/task.py b/parallax/task.py
index 10af517..13dbe71 100644
--- a/parallax/task.py
+++ b/parallax/task.py
@@ -119,7 +119,7 @@ class Task(object):
# Create the subprocess. Since we carefully call set_cloexec() on
# all open files, we specify close_fds=False.
self.proc = Popen(self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE,
- close_fds=False, preexec_fn=os.setsid, env=environ)
+ close_fds=False, preexec_fn=os.setsid, env=environ)
self.timestamp = time.time()
if self.inputbuffer:
self.stdin = self.proc.stdin
@@ -172,8 +172,7 @@ class Task(object):
# Set the exitstatus to what it would be if we waited.
self.exitstatus = -signal.SIGKILL
return False
- else:
- return True
+ return True
else:
if self.exitstatus < 0:
message = 'Killed by signal %s' % (-self.exitstatus)
@@ -268,10 +267,9 @@ class Task(object):
if self.verbose:
exc_type, exc_value, exc_traceback = sys.exc_info()
exc = ("Exception: %s, %s, %s" %
- (exc_type, exc_value, traceback.format_tb(exc_traceback)))
+ (exc_type, exc_value, traceback.format_tb(exc_traceback)))
else:
exc = str(e)
self.failures.append(exc)
# vim:ts=4:sw=4:et:
-
diff --git a/parallax/version.py b/parallax/version.py
index 6732d5a..33f9c5a 100644
--- a/parallax/version.py
+++ b/parallax/version.py
@@ -1 +1 @@
-VERSION = '1.0.2'
+VERSION = '1.0.3'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/parallax.git
More information about the Python-modules-commits
mailing list