6 Commits
Author SHA1 Message Date
c-my 37682a64fe update README 2021-07-18 17:58:49 +08:00
c-my d159c693c6 fix import error 2021-07-18 17:10:42 +08:00
c-my 79d861b5b0 add prompt for wrong password or username 2021-07-17 17:41:56 +08:00
c-my e22e5b6a82 fix typing hint error 2021-07-17 17:01:19 +08:00
c-my b425e5b21c fix typing hint error 2021-07-17 17:00:54 +08:00
c-my b41386eec7 update README 2021-07-17 16:24:09 +08:00
9 changed files with 42 additions and 9 deletions

No files matched your search

+2 -1
View File
@@ -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>
+16 -1
View File
@@ -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 -1
View File
@@ -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.
+4
View File
@@ -0,0 +1,4 @@
from srunbit.cli import execute
if __name__ == '__main__':
execute()
+3
View File
@@ -0,0 +1,3 @@
from srunbit.cli.command import execute
__all__ = [execute]
+7
View File
@@ -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 -2
View File
@@ -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):
-4
View File
@@ -1,4 +0,0 @@
import cli
if __name__ == '__main__':
cli.execute()
+7
View File
@@ -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