Skip to content

Commit accc4d1

Browse files
authored
Merge pull request #4 from xingweitian/dev
v0.1.1 -> v0.1.2
2 parents 769871a + 02a5eac commit accc4d1

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

README.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
This is a convenient tool to fund your WatCard easily. I am too lazy to do it by my hand everytime, so I write this tool.
66

7-
For now, it is only tested in __Ubuntu18.04__ with __Python3.6__.
8-
97
## installation
108

119
```bash
@@ -14,31 +12,18 @@ pip install fund-my-watcard
1412

1513
## usage
1614

17-
First, set the path to your chromedriver as environment variable:
18-
19-
```bash
20-
export CHROMEDRIVER="/path/to/chromedriver"
21-
```
22-
23-
Check if the path of chromedriver is correct:
24-
2515
```bash
26-
env | grep CHROMEDRIVER
27-
```
28-
29-
Find and download the corresponding versions of your chrome at [here](http://chromedriver.chromium.org/downloads)
16+
teachertian@v1040-wn-rt-c-83-249 ~/PycharmProjects/fundmywatcard ±dev⚡ » watcard
17+
usage: watcard [-h] [-c | -f FUND | -v]
3018

31-
Then, try the following commands:
32-
33-
```bash
34-
# see the help of watcard
35-
watcard --help
19+
Fund my WatCard: A tool to fund WatCard easily.
3620

37-
# gengerate the config file
38-
watcard --config
21+
optional arguments:
22+
-h, --help show this help message and exit
23+
-c, --config generate the config file
24+
-f FUND, --fund FUND the fund amount to the WatCard
25+
-v, --version show the version of fund-my-watcard
3926

40-
# fund your WatCard with $10
41-
watcard --fund 10
4227
```
4328

4429
## contributing

fund-my-watcard/watcard

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import os
66
import time
77

88
from splinter import Browser
9+
from webdriver_manager.chrome import ChromeDriverManager
910

1011

1112
def generate_config_file():
@@ -30,7 +31,7 @@ def generate_config_file():
3031
with open("watcard.json", "w+") as json_file:
3132
json.dump(_config_info, json_file, indent=2)
3233
assert os.path.isfile("watcard.json") is True
33-
print("Generate config file successfully. Please fill your information in watcard.json")
34+
print("[fund-my-watcard] Generate config file successfully. Please fill your information in watcard.json")
3435

3536

3637
class MyWatCard:
@@ -55,7 +56,7 @@ class MyWatCard:
5556

5657
def add_fund(self, amount):
5758
try:
58-
with Browser("chrome", **{"executable_path": os.environ["CHROMEDRIVER"]}, incognito=True,
59+
with Browser("chrome", **{"executable_path": ChromeDriverManager().install()}, incognito=True,
5960
headless=True) as browser:
6061
browser.visit("https://watcard.uwaterloo.ca/OneWebUW/addfunds_watiam.asp")
6162
browser.fill("UserName", self.userName)
@@ -95,7 +96,7 @@ class MyWatCard:
9596
class NoConfigFileException(Exception):
9697
"""Raised when watcard.json is not found."""
9798

98-
def __init__(self, message="Cannot find watcard.json, run 'watcard --config' at first."):
99+
def __init__(self, message="[fund-my-watcard] Cannot find watcard.json, try 'watcard --config'."):
99100
super(NoConfigFileException, self).__init__(message)
100101
self.message = message
101102

@@ -104,6 +105,7 @@ parser = argparse.ArgumentParser(description="Fund my WatCard: A tool to fund Wa
104105
group = parser.add_mutually_exclusive_group()
105106
group.add_argument("-c", "--config", help="generate the config file", action="store_true")
106107
group.add_argument("-f", "--fund", type=float, help="the fund amount to the WatCard", action="store")
108+
group.add_argument("-v", "--version", help="show the version of fund-my-watcard", action="store_true")
107109
args = parser.parse_args()
108110

109111
if args.config:
@@ -117,11 +119,14 @@ if args.fund:
117119
_my_wat_card = MyWatCard(**_config)
118120
res = _my_wat_card.add_fund(amount)
119121
if res:
120-
print("Adding ${} to account {} successfully.".format(amount, _config["userName"]))
122+
print("[fund-my-watcard] Adding ${} to account {} successfully.".format(amount, _config["userName"]))
121123
else:
122-
print("Adding ${} to account {} failed.".format(amount, _config["userName"]))
124+
print("[fund-my-watcard] Adding ${} to account {} failed.".format(amount, _config["userName"]))
123125
else:
124126
raise NoConfigFileException()
125127

126-
if not args.config and not args.fund:
127-
args = parser.parse_args(["-h"])
128+
if args.version:
129+
print("fund-my-watcard v0.1.2")
130+
131+
if not args.config and not args.fund and not args.version:
132+
parser.parse_args(["-h"])

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ selenium==3.141.0
22
splinter==0.10.0
33
urllib3==1.25.3
44
six==1.12.0
5+
webdriver-manager==1.7

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name="fund-my-watcard",
16-
version="0.1.1",
16+
version="0.1.2",
1717
packages=find_packages(),
1818
scripts=["fund-my-watcard/watcard"],
1919
install_requires=requirements,
@@ -25,8 +25,9 @@
2525
keywords="WatCard",
2626
url="https://github.com/xingweitian/fund-my-watcard",
2727
classifiers=[
28-
"Development Status :: 3 - Alpha",
2928
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
29+
"Programming Language :: Python :: 3.4",
30+
"Programming Language :: Python :: 3.5",
3031
"Programming Language :: Python :: 3.6",
3132
],
3233
)

0 commit comments

Comments
 (0)