Skip to content

sals.process cleanup/refactor #555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 123 commits into from
Mar 11, 2021
Merged
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
3cccf8a
refactor: remove unused import statements
sameh-farouk Jan 25, 2021
fe83c26
chore: Commenting the code
sameh-farouk Feb 1, 2021
e280c09
docs: Update excute() docstring
sameh-farouk Feb 1, 2021
11a8152
refactor: Refactoring is_alive() & update its docstring
sameh-farouk Feb 1, 2021
79841c4
refactor: Refactoring is_installed()
sameh-farouk Feb 1, 2021
a9b30a0
fix: Re-implementing kill() to fix a bug -> #557
sameh-farouk Feb 1, 2021
516f411
refactor: Refactoring get_pids()
sameh-farouk Feb 1, 2021
41c5670
refactor: Refactoring get_process_object
sameh-farouk Feb 1, 2021
2869464
docs: Restyling the docstring to match google style
sameh-farouk Feb 1, 2021
a0d7e24
refactor: Refactoring check_running()
sameh-farouk Feb 1, 2021
8eacd6f
docs: Updating check_running docsring
sameh-farouk Feb 1, 2021
b06b37c
refactor: Refactoring check_start()
sameh-farouk Feb 1, 2021
99be231
refactor: Refactoring check_start()
sameh-farouk Feb 1, 2021
d9f73b9
refactor: Refactoring check_stop()
sameh-farouk Feb 1, 2021
de8f535
refactor: Refactoring ps_find()
sameh-farouk Feb 1, 2021
67231a0
refactor: Refactoring kill_all()
sameh-farouk Feb 1, 2021
76d9155
refactor: Refactoring kill_process_by_name()
sameh-farouk Feb 1, 2021
b59153c
refactor: Re-implementing get_defunct_processes()
sameh-farouk Feb 1, 2021
eb1ea86
refactor: Refactoring is_port_listening()
sameh-farouk Feb 1, 2021
5b1a762
refactor: Refactoring get_user_processes()
sameh-farouk Feb 1, 2021
815628e
refactor: Refactoring get_similar_processes()
sameh-farouk Feb 1, 2021
f89eede
refactor: Refactoring kill_user_processes()
sameh-farouk Feb 1, 2021
a0814b7
refactor: Refactoring check_process_for_pid()
sameh-farouk Feb 1, 2021
4c2964e
refactor: Refactoring set_env_var()
sameh-farouk Feb 1, 2021
c9cc957
fix: Re-implementing get_process_by_port() issue #561
sameh-farouk Feb 1, 2021
1fb04d0
refactor: Refactoring get_pid_by_port
sameh-farouk Feb 1, 2021
a4ae532
docs: Updating the docstring
sameh-farouk Feb 1, 2021
43900f8
docs: Updating the docstring
sameh-farouk Feb 1, 2021
e0c7650
refactor: Refactoring kill_process_by_port
sameh-farouk Feb 1, 2021
60ee42d
docs: Updating get_processes() docstring
sameh-farouk Feb 1, 2021
d556663
docs: Updating get_ports_mapping() docstring
sameh-farouk Feb 1, 2021
49d7445
docs: Updating get_memory_usage() docstring
sameh-farouk Feb 1, 2021
b6f128f
refactor: Refactoring get_environ()
sameh-farouk Feb 1, 2021
a2cca8e
feature: Re-implementing get_processes_info() -> #467
sameh-farouk Feb 1, 2021
42efde7
refactor: Refactoring get_pids_filtered_by_regex()
sameh-farouk Feb 1, 2021
9b20ab1
refactor: Re-implementing get_pids_filtered_sorted() -> issue #467
sameh-farouk Feb 1, 2021
20995cd
refactor: Re-implementing get_filtered_pids()
sameh-farouk Feb 1, 2021
4cf0d42
docs: Updating the docstr
sameh-farouk Feb 1, 2021
ab961b9
refactor: sorting imports and remove the unused
sameh-farouk Feb 1, 2021
be9999f
docs: Updating the module docstring and outdated examples
sameh-farouk Feb 1, 2021
e610686
tests: Updating few tests to keep up with the sal changes
sameh-farouk Feb 1, 2021
297c371
fix: Retunning True from kill() when the process no longer exists
sameh-farouk Feb 2, 2021
36541b6
feature: Skipping errors when killing multiple Processes
sameh-farouk Feb 2, 2021
858a9ff
feat: Adding logging to kill()
sameh-farouk Feb 2, 2021
7ff1da4
docs: Upadting kill_all() and kill_process_by_name() docstrings
sameh-farouk Feb 3, 2021
9b0ae5d
docs: Upadting get_pid_by_port() and get_process_by_port() docstrings
sameh-farouk Feb 3, 2021
635effd
feat: Adding new function kill_proc_tree()
sameh-farouk Feb 3, 2021
3f04dd4
docs: Updating get_pids_filtered_sorted() docstring
sameh-farouk Feb 3, 2021
8f1322d
feat: Adding logging to get_filtered_pids()
sameh-farouk Feb 3, 2021
d6db842
test: Updating get_user_processes() test
sameh-farouk Feb 3, 2021
4e1c238
test: Updating get_user_processes() test
sameh-farouk Feb 3, 2021
cedd567
feat: Adding logging to get_user_processes()
sameh-farouk Feb 3, 2021
7b81b36
feat: Adding logging to check_start()
sameh-farouk Feb 3, 2021
b9fd01b
docs: Updating kill_proc_tree() docstring
sameh-farouk Feb 3, 2021
0d55415
refactor: modifiy kill_user_processes() to return Process objects
sameh-farouk Feb 3, 2021
4fe0361
fix: Fixing get_processes_info() returns None
sameh-farouk Feb 3, 2021
afe15c2
fix: Restoring accidentally deleted? functionality for get_processes_…
sameh-farouk Feb 3, 2021
8391903
feat: Adding logging to check_stop()
sameh-farouk Feb 3, 2021
5bf9967
tests: Adding debuging code in test_process.py
sameh-farouk Feb 3, 2021
e1fd625
Adding Debug code investigating a build issue
sameh-farouk Feb 3, 2021
5951865
fix: Fixing get_pids_filtered_sorted return process objects not list[…
sameh-farouk Feb 3, 2021
161a215
fix: Fixing AttributeError raised from get_pids_filtered_sorted()
sameh-farouk Feb 3, 2021
a119f42
docs: Updating get_processes_info() docstring
sameh-farouk Feb 3, 2021
aae8120
fix: Updating default_predicate()
sameh-farouk Feb 3, 2021
e26de87
fix: Updating get_pids()
sameh-farouk Feb 4, 2021
1860a71
docs: Re-generating docs
sameh-farouk Feb 4, 2021
73f94a1
fix: Fixing test_22_get_sorted_pids
sameh-farouk Feb 4, 2021
b4c7812
Revert "fix: Updating default_predicate()"
sameh-farouk Feb 4, 2021
ec1a91b
tests: Fixing bug in test_process.get_process_pids()
sameh-farouk Feb 4, 2021
c3ee7e0
Update test_process.py
sameh-farouk Feb 4, 2021
1bba426
tests: Fixing tests
sameh-farouk Feb 4, 2021
01fe132
Merge branch 'development_sal_process_iss467' of https://github.com/t…
sameh-farouk Feb 4, 2021
a868221
tests: revert last merge
sameh-farouk Feb 4, 2021
4feed66
tests: Fixing tests
sameh-farouk Feb 4, 2021
0f4745d
tests: Fixing typo
sameh-farouk Feb 4, 2021
6942536
tests: Fixing bug in getting username
sameh-farouk Feb 4, 2021
b89d225
feat: get_pids now ignoring zombie processes by default
sameh-farouk Feb 4, 2021
708bf24
fix: change get_pids() default sort direction to Asc
sameh-farouk Feb 4, 2021
4d007f1
docs: Updating get_pids() docstring
sameh-farouk Feb 4, 2021
d6a899a
tests: Fixing Defunct processes are reported with pgrep.
sameh-farouk Feb 4, 2021
77cf0c6
tests: Fixing tests
sameh-farouk Feb 4, 2021
c0cccfe
tests: Fixing getting current user name (in portable way)
sameh-farouk Feb 4, 2021
b237380
Adding a new arg `full_cmd_line` to get_pids()
sameh-farouk Feb 7, 2021
3be9009
tests: fixing test_12_get_processes_info
sameh-farouk Feb 7, 2021
8dcc973
fix: Implementing _alt_source in get_pids()
sameh-farouk Feb 7, 2021
fcabc46
refactor: Removing debug code
sameh-farouk Feb 7, 2021
178b1c2
refactor: Removing redundant code
sameh-farouk Feb 7, 2021
3d859db
refactor: Updating the default_predicate()
sameh-farouk Feb 7, 2021
5e4019d
refactor: split str command line using shlex.split() instead of str.s…
sameh-farouk Feb 7, 2021
9c35b09
tests: quoting tmux start command arg
sameh-farouk Feb 7, 2021
45d8b07
refacotr: Enhance get_pids() performance
sameh-farouk Feb 7, 2021
30dd856
tests: excaping the backslash in the regex pattern
sameh-farouk Feb 7, 2021
83556fe
Adding debuging code
sameh-farouk Feb 7, 2021
349ef1b
tests: Adding exact arg to get_process_pids()
sameh-farouk Feb 7, 2021
c9d30f1
Add debugging code
sameh-farouk Feb 7, 2021
ff93b55
refactor: Adding delay arg to check_stop() and check_start()
sameh-farouk Feb 7, 2021
0e786aa
tests: Disable match againest full cmdline when `exact` arg set to True
sameh-farouk Feb 7, 2021
560ba69
docs: Addding examples in the module docstring
sameh-farouk Feb 8, 2021
e0b06d1
docs: completing and formating docstrings
sameh-farouk Feb 8, 2021
a0abf80
Removing some debug messages
sameh-farouk Feb 8, 2021
c628168
refactor: Adding timeout arg to check_stop() and check_start()
sameh-farouk Feb 8, 2021
95dc897
refactor: Adding `sig` and `timeout` args to kill_user_processes()
sameh-farouk Feb 8, 2021
09cd209
feat: Adding new function kill_all_pids()
sameh-farouk Feb 8, 2021
6e7285a
refactor:Now kill() return `None` when succeed
sameh-farouk Feb 9, 2021
8909ca4
refactor:Now check_start() return `None` when succeed
sameh-farouk Feb 9, 2021
770813f
refactor:Now check_stop() return `None` when succeed
sameh-farouk Feb 9, 2021
33ef341
tests: Adapting to Change in process.kill() return value
sameh-farouk Feb 9, 2021
038ab08
tests: Adapting to Change in process.kill() return value
sameh-farouk Feb 9, 2021
56e5d22
refactor:Now kill_process_by_port() doesn't expect return value from …
sameh-farouk Feb 9, 2021
d4903a6
refactor: Simplifying long ternary operator statement as suggested by…
sameh-farouk Feb 9, 2021
2c32fb0
fix: Removing misplaced and redundant try/except
sameh-farouk Feb 9, 2021
b56960a
refactor: Removing redundant debug message
sameh-farouk Feb 9, 2021
fc1e190
refactor:kill_all() now deprecated and removed in favor of kill_proce…
sameh-farouk Feb 9, 2021
9e32165
tests: Adapting and replacing kill_all() with kill_process_by_name()
sameh-farouk Feb 9, 2021
d155eb3
fix:change default `die` arg value to False for get_process_object()
sameh-farouk Feb 9, 2021
7ada6dd
refactor: Updating set_env_var() remove redundant try/except statment
sameh-farouk Feb 9, 2021
eda33d9
Docs: Updating docstring
sameh-farouk Feb 9, 2021
3fd9adf
Docs: Updating get_suer_processes() docstring
sameh-farouk Feb 10, 2021
0f0f617
refactor: Raising proper exception type
sameh-farouk Feb 10, 2021
16dd253
fix: Skipping a test that require root privileges, if user is not root
sameh-farouk Feb 10, 2021
83db70b
refactor: apply a suggested change
sameh-farouk Mar 3, 2021
530bfd6
more cleanup with @sameh-farouk
abom Mar 7, 2021
17247d6
simplify get_pids predicate matching for processes
abom Mar 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Refactoring set_env_var()
- renaming args to more readable names.
- Updating the docstring.
  • Loading branch information
sameh-farouk committed Feb 1, 2021
commit 4c2964e7bec6ce4cbcbe56da976fbdc1c687d12a
17 changes: 9 additions & 8 deletions jumpscale/sals/process/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,18 @@ def check_process_for_pid(pid, process_name):
return False


def set_env_var(varnames, varvalues):
"""Set the value of the environment variables C{varnames}. Existing variable are overwritten

Arguments:
varnames {list(str)} -- A list of the names of all the environment variables to set
varvalues {list(str)} -- A list of all values for the environment variables
def set_env_var(var_names, var_values):
"""Set the value of the environment variables {varnames}. Existing variable are overwritten

Args:
var_names list[str]: A list of the names of all the environment variables to set
varvalues list[str]: A list of all values for the environment variables
Raises:
j.exceptions.RuntimeError: if error happened during setting the environment variables
"""
try:
for i in range(len(varnames)):
os.environ[varnames[i]] = str(varvalues[i]).strip()
for i in range(len(var_names)):
os.environ[var_names[i]] = str(var_values[i]).strip()
except Exception as e:
raise j.exceptions.RuntimeError(e)

Expand Down