From d90b67c1b90125754c0bc5397c0fb736386f8091 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:06:56 +0800 Subject: [PATCH 01/25] add test func(unfinished --- hust_login/__main__.py | 36 ++++++++++++++++++++++++++++++++++++ hust_login/autotest.py | 22 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 hust_login/__main__.py create mode 100644 hust_login/autotest.py diff --git a/hust_login/__main__.py b/hust_login/__main__.py new file mode 100644 index 0000000..9c2639a --- /dev/null +++ b/hust_login/__main__.py @@ -0,0 +1,36 @@ +import sys +import getopt + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:],'U:P:',['autotest']) + except: + print('USAGE: python -m hust_pass --autotest') + + bad_param = False + autotest = False + + for opt,arg in opts: + if opt in ['--autotest']: + autotest = True + elif opt =='-U': + Uid = arg + elif opt == '-P': + Pwd = arg + else: + bad_param = True + break + + if bad_param: + print('USAGE: python -m hust_pass --autotest') + return + if autotest: + from .autotest import full_test + try: + code = full_test(Uid,Pwd) + except: + print('Test Failed') + return code + +if __name__ == '__main__': + main() diff --git a/hust_login/autotest.py b/hust_login/autotest.py new file mode 100644 index 0000000..f9168e8 --- /dev/null +++ b/hust_login/autotest.py @@ -0,0 +1,22 @@ +from . import HustPass + +def full_test(Uid,Pwd): + hpass = HustPass(Uid, Pwd) + try: + hpass.QueryCurriculum('2023-04-27') + hpass.QueryCurriculum(['2023-04-27','2023-03-27','2023-04-07']) + hpass.QueryCurriculum(8) + hpass.QueryCurriculum(('2023-04-01','2023-04-12')) + except: + return 10 + try: + hpass.QueryElectricityBills('2023-04-27') + hpass.QueryElectricityBills(['2023-04-27','2023-03-27','2023-04-07']) + hpass.QueryElectricityBills(('2023-04-01','2023-04-12')) + except: + return 20 + try: + hpass.QueryFreeRoom('2023-09-02') + except: + return 30 + return 0 \ No newline at end of file From 124b560210b31d18ed270d1169ac2e018fb3f117 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:07:22 +0800 Subject: [PATCH 02/25] try to add ci and test --- .github/workflows/auto-test.yml | 47 ++++++++++++++++++++++++++++++ .github/workflows/python-push.yml | 48 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/auto-test.yml create mode 100644 .github/workflows/python-push.yml diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml new file mode 100644 index 0000000..28f33f5 --- /dev/null +++ b/.github/workflows/auto-test.yml @@ -0,0 +1,47 @@ +name: Automated Testing of Interface Availability + +on: + workflow_call: + inputs: + name: + required: true + typing: string + secrets: + Uid: + required: true + typing: string + Pwd: + required: true + typing: string +jobs: + test: + runs-on: + os: ubuntu-latest + + strategy: + matrix: + os: ubuntu-latest #[windows-latest, macos-latest, ubuntu-latest] + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.name }} + + - name: Set up python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ${{ inputs.name }} + python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} + + #- name: release + # uses: softprops/action-gh-release@v1 + # with: + # files: "dist/**" + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml new file mode 100644 index 0000000..aaf5cf6 --- /dev/null +++ b/.github/workflows/python-push.yml @@ -0,0 +1,48 @@ +name: Continuous Integration + +on: [push,pull_request] + +job: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: ubuntu-latest #[windows-latest, macos-latest, ubuntu-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade setuptools + pip install build + + - name: Build package + run: python -m build + + - name: upload artifacts + uses: actions/upload-artifact@v2 + with: + name: hust_login_${{ matrix.os }} + path: dist + + - name: cleanup artifacts + run: rm -r dist + + - name: auto test + call-workflow-passing-data: + uses: /.github/workflows/python-push.yml + with: + name: hust_login_${{ matrix.os }} + secrets: + Uid: ${{ secrets.Uid }} + Pwd: ${{ secrets.Pwd }} + \ No newline at end of file From 72010af20db7699d3e6e49f0d885c3277d8d6e0e Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:18:39 +0800 Subject: [PATCH 03/25] fix bug --- .github/workflows/auto-test.yml | 9 +++------ .github/workflows/python-push.yml | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 28f33f5..71e482b 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -5,22 +5,19 @@ on: inputs: name: required: true - typing: string + type: string secrets: Uid: required: true - typing: string Pwd: required: true - typing: string jobs: test: - runs-on: - os: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: - os: ubuntu-latest #[windows-latest, macos-latest, ubuntu-latest] + os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] steps: - name: Download artifacts diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index aaf5cf6..283cd10 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -1,14 +1,16 @@ name: Continuous Integration -on: [push,pull_request] +on: + push: + pull_request: -job: +jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: - os: ubuntu-latest #[windows-latest, macos-latest, ubuntu-latest] + os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] steps: - name: Checkout code @@ -37,12 +39,12 @@ job: - name: cleanup artifacts run: rm -r dist - - name: auto test - call-workflow-passing-data: - uses: /.github/workflows/python-push.yml - with: - name: hust_login_${{ matrix.os }} - secrets: - Uid: ${{ secrets.Uid }} - Pwd: ${{ secrets.Pwd }} - \ No newline at end of file + #- name: auto test + # call-workflow-passing-data: + # uses: /.github/workflows/python-push.yml + # with: + # name: hust_login_${{ matrix.os }} + # secrets: + # Uid: ${{ secrets.Uid }} + # Pwd: ${{ secrets.Pwd }} + # \ No newline at end of file From 2e07911b826a830ca1d004a69eddd4ce1fcb36ab Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:23:46 +0800 Subject: [PATCH 04/25] addback test --- .github/workflows/python-push.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 283cd10..51eb40e 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -31,7 +31,7 @@ jobs: run: python -m build - name: upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: hust_login_${{ matrix.os }} path: dist @@ -39,12 +39,8 @@ jobs: - name: cleanup artifacts run: rm -r dist - #- name: auto test - # call-workflow-passing-data: - # uses: /.github/workflows/python-push.yml - # with: - # name: hust_login_${{ matrix.os }} - # secrets: - # Uid: ${{ secrets.Uid }} - # Pwd: ${{ secrets.Pwd }} - # \ No newline at end of file + - name: auto test + uses: ./.github/workflows/python-push.yml + with: + name: hust_login_${{ matrix.os }} + \ No newline at end of file From 0664e43046a92ea9b64f2e5377d3822a2676c472 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:30:32 +0800 Subject: [PATCH 05/25] try to fix --- .github/workflows/python-push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 51eb40e..1022527 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -39,6 +39,9 @@ jobs: - name: cleanup artifacts run: rm -r dist + - name: Checkout code again + uses: actions/checkout@v3 + - name: auto test uses: ./.github/workflows/python-push.yml with: From 31da6032d73e332594eb41905613213368cb5670 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:32:21 +0800 Subject: [PATCH 06/25] ? --- .github/workflows/python-push.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 1022527..9336a40 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -37,10 +37,7 @@ jobs: path: dist - name: cleanup artifacts - run: rm -r dist - - - name: Checkout code again - uses: actions/checkout@v3 + run: rm -r dist && tree - name: auto test uses: ./.github/workflows/python-push.yml From 85b880dcd31590e64896279ee97080d3f06c7d75 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:36:14 +0800 Subject: [PATCH 07/25] try again --- .github/workflows/python-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 9336a40..41eb94c 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -37,10 +37,10 @@ jobs: path: dist - name: cleanup artifacts - run: rm -r dist && tree + run: rm -r dist && ls -a - name: auto test - uses: ./.github/workflows/python-push.yml + uses: ./.github/workflows/auto-test.yml with: name: hust_login_${{ matrix.os }} \ No newline at end of file From 44e93b3a7c3904ae91c1fb34bd14a8f5e28ee1b5 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:38:54 +0800 Subject: [PATCH 08/25] .. --- .github/workflows/python-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 41eb94c..67b61e1 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -37,7 +37,7 @@ jobs: path: dist - name: cleanup artifacts - run: rm -r dist && ls -a + run: rm -r dist && cat /home/runner/work/HustLogin/HustLogin/.github/workflows/auto-test.yml - name: auto test uses: ./.github/workflows/auto-test.yml From d860ab7b0f827c7a8cd1e716b98300ffc3b5784b Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 14:40:53 +0800 Subject: [PATCH 09/25] tmp rm auto test --- .github/workflows/python-push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index 67b61e1..ba9d5c3 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -39,8 +39,8 @@ jobs: - name: cleanup artifacts run: rm -r dist && cat /home/runner/work/HustLogin/HustLogin/.github/workflows/auto-test.yml - - name: auto test - uses: ./.github/workflows/auto-test.yml - with: - name: hust_login_${{ matrix.os }} + #- name: auto test + # uses: ./.github/workflows/auto-test.yml + # with: + # name: hust_login_${{ matrix.os }} \ No newline at end of file From 994474ac2984036207e83094bc959974f1e61e02 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:05:07 +0800 Subject: [PATCH 10/25] try trig build by test --- .github/workflows/auto-test.yml | 30 ++++++++++++++++-------------- .github/workflows/python-push.yml | 7 +------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 71e482b..1755bec 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -1,17 +1,17 @@ name: Automated Testing of Interface Availability on: - workflow_call: - inputs: - name: - required: true - type: string - secrets: - Uid: - required: true - Pwd: - required: true + push: + pull_request: jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Build artifacts + id: build + uses: ./github/workflows/python-push.yml + test: runs-on: ${{ matrix.os }} @@ -20,10 +20,11 @@ jobs: os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] steps: + - name: Build artifacts + uses: ./github/workflows/python-push.yml + - name: Download artifacts uses: actions/download-artifact@v3 - with: - name: ${{ inputs.name }} - name: Set up python uses: actions/setup-python@v3 @@ -33,8 +34,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install ${{ inputs.name }} - python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} + tree && ls -a + # pip install ${{ inputs.name }} + # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} #- name: release # uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index ba9d5c3..d4d7c78 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -1,8 +1,7 @@ name: Continuous Integration on: - push: - pull_request: + workflow_call: jobs: build: @@ -39,8 +38,4 @@ jobs: - name: cleanup artifacts run: rm -r dist && cat /home/runner/work/HustLogin/HustLogin/.github/workflows/auto-test.yml - #- name: auto test - # uses: ./.github/workflows/auto-test.yml - # with: - # name: hust_login_${{ matrix.os }} \ No newline at end of file From 087e4148b36e0d1141d1437b153730a67b394d0f Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:07:04 +0800 Subject: [PATCH 11/25] checkout code 1st --- .github/workflows/auto-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 1755bec..19bae18 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -8,6 +8,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Build artifacts id: build uses: ./github/workflows/python-push.yml From 9f0e34f3cd42852aa531732bc5f60cb991cd363e Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:09:14 +0800 Subject: [PATCH 12/25] fix path --- .github/workflows/auto-test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 19bae18..9427680 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -10,10 +10,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Build artifacts id: build - uses: ./github/workflows/python-push.yml + uses: ./.github/workflows/python-push.yml test: runs-on: ${{ matrix.os }} @@ -23,9 +23,6 @@ jobs: os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] steps: - - name: Build artifacts - uses: ./github/workflows/python-push.yml - - name: Download artifacts uses: actions/download-artifact@v3 From 78c07de67da36fe062f0a7b34990d76d2ae83561 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:12:11 +0800 Subject: [PATCH 13/25] try rename --- .github/workflows/auto-test.yml | 2 +- .github/workflows/{python-push.yml => build.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{python-push.yml => build.yml} (100%) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 9427680..a7fd924 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -13,7 +13,7 @@ jobs: - name: Build artifacts id: build - uses: ./.github/workflows/python-push.yml + uses: ./.github/workflows/build.yml test: runs-on: ${{ matrix.os }} diff --git a/.github/workflows/python-push.yml b/.github/workflows/build.yml similarity index 100% rename from .github/workflows/python-push.yml rename to .github/workflows/build.yml From 02fb699c238c366bcdb852ade5fdbdd472941fe0 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:20:43 +0800 Subject: [PATCH 14/25] again --- .github/workflows/auto-test.yml | 1 - .github/workflows/build.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index a7fd924..c8c087a 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -12,7 +12,6 @@ jobs: uses: actions/checkout@v3 - name: Build artifacts - id: build uses: ./.github/workflows/build.yml test: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d4d7c78..64a6307 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: workflow_call: jobs: - build: + build-whl: runs-on: ${{ matrix.os }} strategy: From 8e79b25ef989163d405ef29867837ac35cff2672 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:39:50 +0800 Subject: [PATCH 15/25] give up import, cp the process in file --- .github/workflows/auto-test.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index c8c087a..6b30d8f 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -11,8 +11,27 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Build artifacts - uses: ./.github/workflows/build.yml + - name: Set up python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade setuptools + pip install build + + - name: Build package + run: python -m build + + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + path: dist/* + + - name: cleanup artifacts + run: rm -r dist test: runs-on: ${{ matrix.os }} From 6aed9497253acdb778d4223bc9c43400bf8cb57c Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:41:32 +0800 Subject: [PATCH 16/25] link build to test --- .github/workflows/auto-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 6b30d8f..0729588 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -40,6 +40,8 @@ jobs: matrix: os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] + needs: build + steps: - name: Download artifacts uses: actions/download-artifact@v3 From b872d2e4a93c203276b38ea6d890d0b4a1107a19 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:43:34 +0800 Subject: [PATCH 17/25] try to match without version --- .github/workflows/auto-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 0729588..1076f94 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -54,8 +54,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - tree && ls -a - # pip install ${{ inputs.name }} + pip install hust_login-*.whl # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} #- name: release From 0092447c5ae3136281f456030f1a0414529914b4 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:45:28 +0800 Subject: [PATCH 18/25] fix --- .github/workflows/auto-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 1076f94..8414aa1 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -54,6 +54,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + cd artifact pip install hust_login-*.whl # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} From 060c0a33c6d2d04993a7408b1f82a088e2591e7c Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:48:18 +0800 Subject: [PATCH 19/25] enable multiplatform test --- .github/workflows/auto-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 8414aa1..eb57b83 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -38,7 +38,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] + os: [windows-latest, macos-latest, ubuntu-latest] needs: build @@ -56,7 +56,7 @@ jobs: python -m pip install --upgrade pip cd artifact pip install hust_login-*.whl - # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} + python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} #- name: release # uses: softprops/action-gh-release@v1 From c695d3522eb96bec12738485a57804f8bb510653 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:50:56 +0800 Subject: [PATCH 20/25] catch an exception --- hust_login/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hust_login/__main__.py b/hust_login/__main__.py index 9c2639a..00014f7 100644 --- a/hust_login/__main__.py +++ b/hust_login/__main__.py @@ -30,6 +30,7 @@ def main(): code = full_test(Uid,Pwd) except: print('Test Failed') + return -1 return code if __name__ == '__main__': From 60618a9208a0444266dd8e9f9ef2e8b7065252e2 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 15:55:19 +0800 Subject: [PATCH 21/25] try to upload .whl only --- .github/workflows/auto-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index eb57b83..00a2bdd 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -28,7 +28,7 @@ jobs: - name: upload artifacts uses: actions/upload-artifact@v3 with: - path: dist/* + path: dist/hust_login-*.whl - name: cleanup artifacts run: rm -r dist @@ -54,9 +54,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - cd artifact - pip install hust_login-*.whl - python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} + tree + # pip install hust_login-*.whl + # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} #- name: release # uses: softprops/action-gh-release@v1 From 4335c2d48763798d2acb6b38851df4e0441e510a Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 16:00:13 +0800 Subject: [PATCH 22/25] change to mannually trig --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64a6307..b23d143 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: Continuous Integration on: - workflow_call: + workflow_dispatch: jobs: build-whl: @@ -33,9 +33,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: hust_login_${{ matrix.os }} - path: dist + path: dist/hust_login-*.whl - name: cleanup artifacts - run: rm -r dist && cat /home/runner/work/HustLogin/HustLogin/.github/workflows/auto-test.yml + run: rm -r dist \ No newline at end of file From d70d8fc8a1400ec7a9fd6bbfcb592157a4e65779 Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 16:01:16 +0800 Subject: [PATCH 23/25] win ver may not work, removed --- .github/workflows/auto-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 00a2bdd..146af57 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -38,7 +38,7 @@ jobs: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-latest] #[windows-latest, macos-latest, ubuntu-latest] needs: build @@ -54,9 +54,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - tree - # pip install hust_login-*.whl - # python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} + cd artifact + pip install hust_login-*.whl + python -m hust_login --autotest -U ${{ secrets.Uid }} -P ${{ secrets.Pwd }} #- name: release # uses: softprops/action-gh-release@v1 From 7bcac16fe90c5b2fbc62a1c6ffe79b3b3f6019eb Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 17:13:01 +0800 Subject: [PATCH 24/25] update readme, add me --- README.md | 8 +++++++- README_ZH.md | 27 ++++++++++++++------------- hust_login/__init__.py | 2 ++ setup.py | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ae87c43..36cb3fe 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Additionally, you need to install ```tesseract-ocr``` back end: - Linux: run ```sudo apt install tesseract-ocr``` ## Documentation -### **```hust_login.HustPass(username, password, headers=None)```** +### **```hust_login.HustLogin(username, password, headers=None)```** PARAMETERS: - username -- Username of pass.hust.edu.cn e.g. U2022XXXXX @@ -38,6 +38,12 @@ Additionally, you need to install ```tesseract-ocr``` back end: ret = s.get(your_url) print(ret.text) ``` +### **```hust_login.HustLogin(username, password, headers=None)```** + + PARAMETERS: Same as HustLogin + + RETURNS: + - A class that contains wrapped common functions like QueryElectricityBills, QueryCurriculum, QueryFreeRoom, etc. > BE CREATIVE!!! diff --git a/README_ZH.md b/README_ZH.md index 76860c9..a240e87 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,4 +1,4 @@ -#HustPass +# HustPass 用于验证 HustPass@2023 的 python-lib > 更快、更简单、更方便 @@ -15,17 +15,13 @@ pip install hust_login ``` +此外,您需要安装```tesseract-ocr```后端: -依赖如下: -``` -Pillow -pycryptodome -pytesseract -Requests -``` +- Win:[在此处下载二进制文件](https://tesseract-ocr.github.io/tessdoc/Downloads.html),推荐“3rd party Windows exe’s/installer”。 +- Linux:运行```sudo apt install tesseract-ocr``` ## 文档 -### **````hust_login.HustPass(用户名,密码)````** +### **```hust_login.HustLogin(用户名,密码,标头(可选)```** 参数: - 用户名 -- pass.hust.edu.cn 的用户名 例如 U2022XXXXX @@ -35,13 +31,17 @@ Requests 返回: - 已登录的 **```requests.Session```** 对象 - 使用它的方式与使用请求的方式相同,例如 - ````python + ```python s = hust_login.HustPass('U2022XXXXX','您的密码') ret = s.get(your_url) print(ret.text) - ```` + ``` +### **```hust_login.HustPass(用户名,密码,标头(可选))``` -> HustLogin接口已被弃用,请使用HustPass + 参数:与HustLogin相同 + + 返回: + - 一个类,包含QueryElectricityBills,QueryCurriculum,QueryFreeRoom等已包装的常用函数。 > 发挥创意!!! @@ -98,7 +98,7 @@ Requests - PublicKey采用base64编码,请先解码。 - 您加密的usr/pass应该以base64编码,并转换为文本而不是字节。 请更深入地研究我的代码,看看它是如何工作的。 - 解码器 - - “BytesIO”方法用于将包含 gif 的字节流转换为文件。 + - 使用```BytesIO``` 方法将包含 gif 的字节流转换为文件。 - 采用 Genius 方法对 4 帧 gif 进行组合和去噪:据观察,**数量**像素至少会出现在 3 帧中,而**噪声**像素小于 2。这提供了一种超级准确的方法来对图片进行去噪。 这是代码片段,尝试理解: ```python img_merge = Image.new(mode='L',size=(width,height),color=255) @@ -106,5 +106,6 @@ Requests if sum([img.getpixel(pos) < 254 for img in img_list]) >= 3: img_merge.putpixel(pos,0) ``` + ![org](images/captcha_code.gif) ![processed](images/captcha_code_processed.png) - 网络 - 一个常见的假UA是必不可少的! HustPass 已阻止 python-requests 的默认UA。 \ No newline at end of file diff --git a/hust_login/__init__.py b/hust_login/__init__.py index b68c712..8731095 100644 --- a/hust_login/__init__.py +++ b/hust_login/__init__.py @@ -1,6 +1,8 @@ from .login import HustLogin, CheckLoginStatu from . import curriculum # 课表相关归属在此命名空间下 from ._HustPass import HustPass +from . import free_room +from . import utility_bills as bills from importlib.metadata import version, PackageNotFoundError diff --git a/setup.py b/setup.py index 02d0191..1880c07 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ setup_requires=['setuptools_scm'], use_scm_version=True, description='A python-lib for authenticating HustPass@2023', - author='MarvinTerry', - author_email='marvinterry2004@gmail.com', + author='MarvinTerry and Jackhr', + author_email='marvinterry2004@gmail.com and jj2460596@gmail.com', url='https://github.com/MarvinTerry/HustLogin', packages=['hust_login'], license='MIT', From b0a4af79f4d0dc07c3ab099e0d651f5a566aa67c Mon Sep 17 00:00:00 2001 From: Jackhr Date: Mon, 24 Jul 2023 17:14:03 +0800 Subject: [PATCH 25/25] add ico --- README_ZH.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_ZH.md b/README_ZH.md index a240e87..854b161 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,6 +1,8 @@ # HustPass 用于验证 HustPass@2023 的 python-lib +![HustPassLogo](https://pass.hust.edu.cn/cas/comm/image/logo-inside.png) + > 更快、更简单、更方便 注意:HustPass登录协议于2023年5月23日进行了重大更新,从DES迁移到RSA,以前的登录库现已不可使用。