close
Skip to content

Strange drama with the run command when running certain commands #260

@fgimian

Description

@fgimian

Hey there again, I'm really not sure what's special about this particular command, but it's tripping up the run() function.

Here's my code:

import os
from invoke import task, run

@task
def forge():
    proxy = 'http://192.168.0.1:80/'
    os.environ.update({
        'http_proxy': proxy,
        'https_proxy': proxy
    })

    cmd = 'puppet module install --target-dir /var/puppet/forgey puppetlabs-motd'
    print cmd
    run(cmd)

And the output:

puppet module install --target-dir /var/puppet/forgey puppetlabs-motd
Warning: Setting manifest is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Warning: Setting modulepath is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Warning: Setting config_version is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Notice: Preparing to install into /var/puppet/forgey ...
Notice: Created target directory /var/puppet/forgey
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
Traceback (most recent call last):
  File "./bin/invoke", line 12, in <module>
    invoke.cli.main()
  File "/root/puppet-pusher/lib/invoke/invoke/cli.py", line 438, in main
    dispatch(sys.argv)
  File "/root/puppet-pusher/lib/invoke/invoke/cli.py", line 431, in dispatch
    return executor.execute(*tasks)
  File "/root/puppet-pusher/lib/invoke/invoke/executor.py", line 100, in execute
    task=task, name=name, args=args, kwargs=kwargs, config=config
  File "/root/puppet-pusher/lib/invoke/invoke/executor.py", line 153, in _execute
    result = task(*args, **kwargs)
  File "/root/puppet-pusher/lib/invoke/invoke/tasks.py", line 111, in __call__
    result = self.body(*args, **kwargs)
  File "/root/puppet-pusher/tasks.py", line 14, in forge
    run(cmd)
  File "/root/puppet-pusher/lib/invoke/invoke/__init__.py", line 23, in run
    return Context().run(command, **kwargs)
  File "/root/puppet-pusher/lib/invoke/invoke/context.py", line 53, in run
    return runner_class(context=self).run(command, **kwargs)
  File "/root/puppet-pusher/lib/invoke/invoke/runners.py", line 262, in run
    raise ThreadException(exceptions)
invoke.exceptions.ThreadException:
Saw 1 exceptions within threads (UnicodeEncodeError):


Thread args: {'args': [<functools.partial object at 0x1c86f70>,
          <open file '<stdout>', mode 'w' at 0x7effba142150>,
          [u'\x1b[mNotice: Preparing to install into /var/puppet/forgey ...\x1b[0m\n',
           u'\x1b[mNotice: Created target directory /var/puppet/forgey\x1b[0m\n',
           u'\x1b[mNotice: Downloading from https://forgeapi.puppetlabs.com ...\x1b[0m\n',
           u'\x1b[mNotice: Installing -- do not interrupt ...\x1b[0m\n'],
          False],
 'target': <bound method Local.io of <invoke.runners.Local object at 0x1c91b90>>}

Traceback (most recent call last):

  File "/root/puppet-pusher/lib/invoke/invoke/runners.py", line 82, in run
    super(_IOThread, self).run()

  File "/usr/lib64/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)

  File "/root/puppet-pusher/lib/invoke/invoke/runners.py", line 328, in io
    output.write(data)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 19-27: ordinal not in range(128)

This system is using:

  • Python 2.6.6
  • Puppet 3.6.2
  • Invoke (master)

Regular output of the command looks like this:

Warning: Setting manifest is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Warning: Setting modulepath is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Warning: Setting config_version is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Notice: Preparing to install into /var/puppet/forgey ...
Notice: Created target directory /var/puppet/forgey
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/var/puppet/forgey
└── puppetlabs-motd (v1.2.0)

Any ideas?

Cheers
Fotis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions