Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37682a64fe | ||
|
|
d159c693c6 | ||
|
|
79d861b5b0 | ||
|
|
e22e5b6a82 | ||
|
|
b425e5b21c | ||
|
|
b41386eec7 |
No files matched your search
Generated
+2
-1
@@ -2,9 +2,10 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/srunbit" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (srun)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -6,7 +6,13 @@
|
||||
|
||||
### Via binary
|
||||
|
||||
Download binary file from GitHub release page.
|
||||
Download binary file from GitHub [release page](https://github.com/c-my/srun-cli-bit/releases/latest) .
|
||||
(If you are using Linux, you may need to run `chmod +x [binary_file]` first.)
|
||||
|
||||
### Via source
|
||||
1. Clone this repo
|
||||
2. Install dependencies using `pip install -r requirements.txt`
|
||||
3. Run `python src/main.py login`
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -18,7 +24,16 @@ Download binary file from GitHub release page.
|
||||
|
||||
`srun-bit info`: show account information
|
||||
|
||||
## Note
|
||||
### Binary Version Compile Option
|
||||
* Windows10(python3.9.5): `python -m nuitka src/main.py --onefile --standalone --mingw64`
|
||||
* Ubuntu(python3.9.0): `python -m nuitka --onefile --standalone src/main.py`
|
||||
|
||||
**_Windows binary version NOT work on Windows7_**
|
||||
|
||||
## Thanks to
|
||||
|
||||
[https://github.com/vouv/srun](https://github.com/vouv/srun)
|
||||
|
||||
[Nuitka](https://nuitka.net/)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = srun-cli-bit
|
||||
version = 0.1.0
|
||||
version = 0.1.3
|
||||
author = Cai Mingyang
|
||||
author_email = cai.my@outlook.com
|
||||
description = A cli tool for BIT campus network.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from srunbit.cli import execute
|
||||
|
||||
if __name__ == '__main__':
|
||||
execute()
|
||||
@@ -0,0 +1,3 @@
|
||||
from srunbit.cli.command import execute
|
||||
|
||||
__all__ = [execute]
|
||||
@@ -40,6 +40,13 @@ def execute():
|
||||
print('Account in arrear.')
|
||||
elif code == network.LoginCode.ALREADY_ONLINE:
|
||||
print('Account already online.')
|
||||
elif code == network.LoginCode.WRONG_PASSWORD:
|
||||
print('Wrong password.')
|
||||
elif code == network.LoginCode.USER_DISABLED:
|
||||
print('User disabled.')
|
||||
else:
|
||||
print('Login failed.')
|
||||
|
||||
elif action == 'logout':
|
||||
account = store.read_account()
|
||||
if account is None:
|
||||
|
||||
@@ -2,7 +2,7 @@ import base64
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
from typing import Dict
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
def gen_info(data: Dict, token: str) -> str:
|
||||
@@ -68,7 +68,7 @@ def _x_encode(msg: str, key: str) -> str:
|
||||
return _l(v, False)
|
||||
|
||||
|
||||
def _s(a: str, b: bool) -> list[int]:
|
||||
def _s(a: str, b: bool) -> List[int]:
|
||||
c = len(a)
|
||||
v = []
|
||||
for i in range(0, c, 4):
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import cli
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli.execute()
|
||||
@@ -16,6 +16,8 @@ class LoginCode(Enum):
|
||||
SUCCEED = 1
|
||||
ALREADY_ONLINE = 2
|
||||
ARREARAGE = 3
|
||||
WRONG_PASSWORD = 4
|
||||
USER_DISABLED = 5
|
||||
|
||||
|
||||
class LogoutCode(Enum):
|
||||
@@ -67,8 +69,13 @@ class Network:
|
||||
return LoginCode.ARREARAGE
|
||||
elif 'You are already online.' in error_msg:
|
||||
return LoginCode.ALREADY_ONLINE
|
||||
elif 'Password is error' in error_msg:
|
||||
return LoginCode.WRONG_PASSWORD
|
||||
elif 'User is disabled' in error_msg:
|
||||
return LoginCode.USER_DISABLED
|
||||
else:
|
||||
logging.debug(f'login res is not ok, got error_msg: {error_msg}')
|
||||
print(json_obj)
|
||||
return LoginCode.FAILED
|
||||
return LoginCode.SUCCEED
|
||||
|
||||
|
||||
Reference in new issue
Block a user