Commit Graph

21 Commits

Author SHA1 Message Date
Eric Radman
6da4fd979b
Check file attributes in check_file_meta() if lsattr(1) is installed
lsattr/chattr is not installed on many Unix-like platforms by default,
including *BSD, Solaris, and minimal Linux distributions such as Alpine.
2017-10-19 18:38:12 -04:00
Erik Johnson
877abb89d0
Complete the salt.utils refactor
This moves the remaining 30 functions from salt.utils to new locations.
2017-10-15 09:43:31 -05:00
Erik Johnson
c6b655b6e9
Move 14 more functions from salt.utils
These functions are:

salt.utils.test_mode -> salt.utils.args.test_mode
salt.utils.split_input -> salt.utils.args.split_input
alt.utils.pem_finger -> salt.utils.crypt.pem_finger
salt.utils.is_bin_file -> salt.utils.files.is_binary
salt.utils.list_files -> salt.utils.files.list_files
salt.utils.safe_walk -> salt.utils.files.safe_walk
salt.utils.st_mode_to_octal -> salt.utils.files.st_mode_to_octal
salt.utils.normalize_mode -> salt.utils.files.normalize_mode
salt.utils.human_size_to_bytes -> salt.utils.files.human_size_to_bytes
salt.utils.get_hash -> salt.utils.hashutils.get_hash
salt.utils.is_list -> salt.utils.data.is_list
salt.utils.is_iter -> salt.utils.data.is_iter
salt.utils.isorted -> salt.utils.data.sorted_ignorecase
salt.utils.is_true -> salt.utils.data.is_true
2017-10-13 09:29:03 -05:00
rallytime
74d315fd28
Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/modules/file.py
  - tests/unit/modules/test_file.py
2017-09-26 13:45:10 -04:00
twangboy
056f3bb4c0
Use with to open temp file 2017-09-25 09:35:25 -06:00
twangboy
716e99c453
Fix py3 bytestring problems 2017-09-25 09:35:24 -06:00
twangboy
543610570c
Fix bytestring issues, fix errored tests 2017-09-25 09:35:24 -06:00
twangboy
9fe83a34a5
Remove old variable declaration 2017-09-25 09:35:23 -06:00
twangboy
c5cf5e92c1
Fix many tests 2017-09-25 09:35:23 -06:00
rallytime
e11aa7e5ef Adjust test mocking to handle __utils__['files.is_text_file'] 2017-09-11 10:25:00 -04:00
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
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
Pedro Algarvio
abe608d739
Drop @patch usage 2017-04-28 13:36:42 +01:00
Pedro Algarvio
d05028e88c
These are not integration tests 2017-04-01 14:22:51 +01:00
Pedro Algarvio
d397763553
Adjust to the new LoaderModuleMockMixin usage 2017-03-28 19:03:59 +01:00
Pedro Algarvio
9b1e55aa85
Import the full module namespace to avoid import shadowing.
https://github.com/saltstack/salt/pull/39996#issuecomment-287857698
2017-03-28 19:02:47 +01:00
Pedro Algarvio
1f7a0aa65b
Proper mocking 2017-03-28 19:00:51 +01:00
Pedro Algarvio
b25b26e23d
Cleanup test attributes once finished 2017-03-28 19:00:51 +01:00
Pedro Algarvio
40a64191a1
Absolute imports and A LOT of code cleanup. 2017-03-01 01:33:07 +00:00
Pedro Algarvio
3beb3fb801
Move whatever we need from salttesting to salt.
Let's drop the salttesting dependency cycle.
2017-02-28 22:52:49 +00:00
Pedro Algarvio
15af4c9728
Test filenames conformity. Adjust for pytest. 2017-02-23 23:19:42 +00:00