Skip to content

Commit

Permalink
Merge pull request rundeck-plugins#46 from aggaatul/bugWhenUsingScripts
Browse files Browse the repository at this point in the history
Bug in script handling in python3
  • Loading branch information
ltamaster authored Oct 31, 2019
2 parents b242c5c + 301f393 commit a7f7996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contents/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
format='%(levelname)s: %(name)s: %(message)s')
log = logging.getLogger('kubernetes-plugin')

PY = sys.version_info[0]

if os.environ.get('RD_JOB_LOGLEVEL') == 'DEBUG':
log.setLevel(logging.DEBUG)

Expand Down Expand Up @@ -385,6 +387,10 @@ def copy_file(name, namespace, container, source_file, destination_path, destina
log.error("ERROR: %s" % resp.read_stderr())
if commands:
c = commands.pop(0)

# Python 3 expects bytes string to transfer the data.
if PY == 3:
c = c.decode()
resp.write_stdin(c)
else:
break
Expand Down
6 changes: 6 additions & 0 deletions contents/pods-run-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
if os.environ.get('RD_JOB_LOGLEVEL') == 'DEBUG':
log.setLevel(logging.DEBUG)

PY = sys.version_info[0]

def main():

Expand Down Expand Up @@ -62,6 +63,11 @@ def main():
exit(1)

script = os.environ.get('RD_CONFIG_SCRIPT')

# Python 3 expects bytes string to transfer the data.
if PY == 3:
script = script.encode('utf-8')

invocation = "/bin/bash"
if 'RD_CONFIG_INVOCATION' in os.environ:
invocation = os.environ.get('RD_CONFIG_INVOCATION')
Expand Down

0 comments on commit a7f7996

Please sign in to comment.