Commit Graph

30 Commits

Author SHA1 Message Date
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
Dmitry Kuzmenko
bf9dd00aac Subscribe event to bus is optional now
Once subscribed to publisher SUB socket gets collecting all incoming
messages that is unwanted behavior for fire-only events.
Fixed by using listen=<True|False> constructor argument.
2015-07-29 17:44:02 +03:00
Damian Myerscough
e597fde260 Remove old commented out listen definition and make parser arguments PEP8 compliant 2015-06-22 21:14:56 -07:00
Mike Place
6acdd30303 Lint 2015-02-14 21:23:54 -07:00
Mike Place
cb7d7653a3 Allow saltutil.refresh_modules to wait for completion
Also added raet support to eventlisten as well as added functionality to connect to
2015-02-13 14:14:47 -07:00
Pedro Algarvio
fe454d4132 Py3 compatibility fixes 2015-01-30 22:25:06 +00:00
Pedro Algarvio
60f215f191 Add from __future__ import absolute_import 2015-01-30 22:25:04 +00:00
Nitin Madhok
c992f04f32 Changing permissions of test files and fixing lint violations 2014-12-19 05:50:18 -05:00
Mike Place
951a434228 +x for eventlisten and minionswarm 2014-11-05 14:49:32 -07:00
Aditya Kulkarni
2d98bc16aa Warn if eventlisten is unable to access socket 2014-08-21 12:53:45 -04:00
Chris Rebert
b7ce0dbe60 more typos after disabling case-sensitivity 2014-08-11 10:57:41 -07:00
Jason Swindle
e773e1fb57 #12989 Fix for '3 arguments (4 given)' error. 2014-05-23 09:45:00 -05:00
Mike Place
e93d73d39c Fix broken eventlisten and small refactor. 2014-04-17 13:30:53 -06:00
Thomas S Hatch
6f284aad59 whitespace 2014-03-18 15:51:09 -06:00
Mike Place
2752e4b019 Duh. Check func. 2014-03-18 14:10:51 -06:00
Mike Place
d4738b6352 New flag for watching minion returns by function. 2014-03-18 13:49:47 -06:00
Pedro Algarvio
69d0f907f9 Make use of the print() function. 2014-02-03 11:07:43 +00:00
Colton Myers
dd2883dff8 Fix eventlisten.py for minion event bus
The sock_dir modification was happening after the minion opts had
already returned.  Just make sure it happens before any return
statement.
2013-11-27 09:39:52 -07:00
Pedro Algarvio
d02a2bc224 Include the python encoding file header on tests. 2013-11-27 11:19:24 +00:00
Thomas S Hatch
f5d4f31952 Doh! node 2013-06-11 16:39:48 -06:00
Thomas S Hatch
fe23e66ce5 Update eventlisten script with sock_dir changes 2013-06-11 16:37:16 -06:00
Chris Rebert
26209c1fc1 rm unused imports reported by pyflakes 2013-04-30 14:48:04 -07:00
Pedro Algarvio
b88d901b78 Allow the event listener to work with the test sockets. And even for the minion's 2013-04-27 20:39:33 +01:00
Thomas S Hatch
8dadd37e0c Fix the sockdir path in eventlisten 2013-02-07 12:37:18 -07:00
Thomas S Hatch
e354080dd7 don explicitly add node on eventlisten 2013-01-17 14:00:53 -07:00
Thomas S Hatch
648e6b8eca Fix eventlisten for changes made to 0.10.6 2012-12-12 13:14:13 -07:00
Thomas S Hatch
c1fc9d6726 fix sock_dir change for eventlisten script 2012-10-15 22:50:31 -06:00
Thomas S Hatch
858d086995 Args got flipped in eventlisten 2012-10-02 13:26:23 -06:00
Intchanter
a1433ef5ec PEP8 fixes for tests 2012-06-30 14:10:34 -06:00
Thomas S Hatch
e6e92fb3af Add eventlisten script to watch events on the master and minion 2012-06-07 18:41:18 -06:00