Skip to content

Commit 4e08fb7

Browse files
committed
beautify the code
1 parent afa8f58 commit 4e08fb7

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
import tunet
1212

1313
if sys.version_info[0] == 2:
14-
import urllib2
15-
URLError = urllib2.URLError
14+
from urllib2 import URLError
1615
else:
17-
import urllib.error
18-
URLError = urllib.error.URLError
16+
from urllib.error import URLError
1917

2018

2119
if __name__ == '__main__':

test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import pprint
42
import tunet
53

@@ -9,5 +7,5 @@
97

108
if __name__ == '__main__':
119
pprint.pprint(tunet.auth4.checklogin())
12-
pprint.pprint(tunet.auth4.login(username, password))
10+
pprint.pprint(tunet.auth4.login(username, password, net=True))
1311
pprint.pprint(tunet.net.checklogin())

tunet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def read_callback(res):
135135
args = json.loads(page)
136136
return args
137137

138-
def _get_challenge(ipv, username, ip):
138+
def get_challenge(ipv, username, ip):
139139
url = _URL_GET_CHALLENGE.format(ipv)
140140
data = {
141141
'callback': _JSONP_FUNCNAME,
@@ -155,7 +155,7 @@ def _auth_login(ipv, username, password, net=False, ip=''):
155155
username = '{:s}@tsinghua'.format(username)\
156156

157157
url = _URL_SRUN_PORTAL.format(ipv)
158-
challenge = _get_challenge(ipv, username, ip)
158+
challenge = get_challenge(ipv, username, ip)
159159
ip = ip or challenge['online_ip']
160160
ac_id = get_ac_id(ip)
161161
n = 200
@@ -214,7 +214,7 @@ def _auth_checklogin(ipv):
214214
def _auth_logout(ipv, ip=''):
215215
url = _URL_SRUN_PORTAL.format(ipv)
216216
username = 'placeholder'
217-
challenge = _get_challenge(ipv, username, ip)
217+
challenge = get_challenge(ipv, username, ip)
218218

219219
ac_id = 1
220220
n = 200

0 commit comments

Comments
 (0)