rishlib 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rishlib/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .corelib import Rish
rishlib/corelib.py ADDED
@@ -0,0 +1,32 @@
1
+ import os, subprocess
2
+
3
+ class Rish:
4
+ def __init__(self, cmd):
5
+ self.cmd = cmd
6
+
7
+ @staticmethod
8
+ def setup(app="com.termux"):
9
+ env = os.environ.copy()
10
+ env["RISH_APPLICATION_APP"] = app
11
+ return env
12
+
13
+ def run(self, env, pref=os.path.expanduser("~/rish"), c=True, timeout=10):
14
+ arg = [pref]
15
+ if c:
16
+ arg.append("-c")
17
+
18
+ arg.append(self.cmd)
19
+
20
+ try:
21
+ res = subprocess.run(
22
+ arg, env=env,
23
+ capture_output=True,
24
+ text=True,
25
+ timeout=timeout)
26
+
27
+ return str(res.stdout).splitlines()
28
+ if res.stderr:
29
+ return res.returncode
30
+
31
+ except Exception as e:
32
+ print(e)
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: rishlib
3
+ Version: 0.1.0
4
+ Summary: ./rish command for python!
5
+ Author: abiyyumc
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+
10
+ # rishlib
11
+ python library that can run cmds with rish!
12
+
13
+ ## how to install
14
+ ```
15
+ pip install rishlib
16
+ ```
17
+ ## How to use
18
+ ```python
19
+ from rishlib import Rish
20
+
21
+ env = Rish.setup(app="com.termux") #default = "com.termux"
22
+ output = Rish(cmd).run(env=env, pref="./rish", c=True, timeout=10)
23
+ # use setup() to setup your rish
24
+ # fill pref arg with "./rish" if your current directory is in rish directory, if not do not fill pref arg
25
+ # c is for "-c"
26
+ ```
27
+ ## Features
28
+ | Function | Result |
29
+ | --- | --- |
30
+ | `Rish.setup()` | Setup your rish by setting the RISH_APPLICATION_ID and return the enviroment dict
31
+ | `Rish(cmd).run(env, pref, c, timeout)` | Run program and return the results
32
+
33
+ ## LISCENSE
34
+ __MIT__
@@ -0,0 +1,6 @@
1
+ rishlib/__init__.py,sha256=jcn0xzg805qmpTQLL93kJOHCAimolPTIviZKiuedvdQ,25
2
+ rishlib/corelib.py,sha256=Jppp6i7EZz7C8c4g0fzWYG1BHWDVj2EifsuWds6l72c,587
3
+ rishlib-0.1.0.dist-info/METADATA,sha256=TpjcqRXtr3-69q_yT3H4ZicSyWR06uEqlnrqhcz4kWE,865
4
+ rishlib-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ rishlib-0.1.0.dist-info/top_level.txt,sha256=j7OtDNyr13JHgF5caKgtrOQ1kbmyqIKzfZGEzyFhnOg,8
6
+ rishlib-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ rishlib