arb-xmu-course 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/arb-xmu-course +38 -34
- data/lib/arb/xmu/course/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa1cdb5d3d96c3a79fd07d63d077978eee9fa01
|
4
|
+
data.tar.gz: 3ff92b1591be12dd60f78699233e87d17f320188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec55e9d04a7a59894d96752ebf0b584c12941543cdb8ed02869c94aac4156c282de91f35f6fa9f9c6f0d78e0565f75be4237304a9b7b95b50c916bd91a735b60
|
7
|
+
data.tar.gz: edb38c3d58380f07663e0c72b2d28c7e7d96b89e1df7e04fe52ece673569969679134253a1600b1e49a37e7dc8bfc5aabe3f91e6c51ef951a4cd64ad298c6d95
|
data/bin/arb-xmu-course
CHANGED
@@ -124,14 +124,14 @@ def create_attempt_thread(max_interval, client, course, xxlx, lcid, &block)
|
|
124
124
|
loop do
|
125
125
|
count+=1
|
126
126
|
interval= 1+rand(max_interval)
|
127
|
-
sleep interval
|
128
127
|
res = request_select_course(client, course, xxlx, lcid)
|
129
128
|
if res['success']
|
130
|
-
global_puts
|
129
|
+
global_puts "《#{course.name}》(#{course.class_name}班)已经成功选课!"
|
131
130
|
break
|
132
131
|
else
|
133
|
-
global_puts
|
132
|
+
global_puts "《#{course.name}》(#{course.class_name}班)第#{count}次尝试选课失败,#{interval}秒后将重试。(#{filter_text(res['message'])})"
|
134
133
|
end
|
134
|
+
sleep interval
|
135
135
|
end
|
136
136
|
opened_thread_count=block.binding.local_variable_get(:opened_thread_count)
|
137
137
|
exit unless opened_thread_count > 0
|
@@ -141,10 +141,10 @@ end
|
|
141
141
|
|
142
142
|
def request_select_course(client, course_entity, xxlx, lcid)
|
143
143
|
msg = client.get 'http://bkxk.xmu.edu.cn/xsxk/elect.html',
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
144
|
+
method: 'handleZxxk',
|
145
|
+
jxbid: course_entity.id,
|
146
|
+
xxlx: xxlx,
|
147
|
+
xklc: lcid
|
148
148
|
JSON::parse msg.body
|
149
149
|
end
|
150
150
|
|
@@ -164,7 +164,7 @@ def process_ids(str_ids)
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def try_to_select_courses(client, courses, xxlx, lcid)
|
167
|
-
global_puts '
|
167
|
+
global_puts '输入要选的课程ID(重复无效,支持语法糖:x-y,会尝试选择ID从x到y的所有课程), 以空格分割:'
|
168
168
|
ids = process_ids(global_gets.split(' '))
|
169
169
|
global_puts '输入最大重试间隔时间,要求不得低于3秒:'
|
170
170
|
max_interval = global_gets.to_i
|
@@ -224,7 +224,11 @@ def filter_text(raw)
|
|
224
224
|
end
|
225
225
|
|
226
226
|
def global_puts(*args)
|
227
|
-
$
|
227
|
+
fileout=File.open($logfile,'a') if $logfile
|
228
|
+
[fileout,$stdout].compact.each do |stream|
|
229
|
+
stream.puts '',Time.now,*args
|
230
|
+
end
|
231
|
+
fileout.close rescue nil
|
228
232
|
end
|
229
233
|
|
230
234
|
def global_gets(*args)
|
@@ -241,12 +245,12 @@ CLIENT = HTTPClient.new
|
|
241
245
|
|
242
246
|
begin
|
243
247
|
opts = Slop.parse do |o|
|
244
|
-
o.banner="为缓解选课服务器压力,请酌情选择较大的“最大重试间隔”,此外,在任何需要输入的地方输入“q”或“quit
|
245
|
-
用法:命令行输入arb-xmu-course[空格][选项],选项在以下列出。 -Powered By AryBin"
|
248
|
+
o.banner="为缓解选课服务器压力,请酌情选择较大的“最大重试间隔”,此外,在任何需要输入的地方输入“q”或“quit”可以结束本程序。 -Powered By AryBin"
|
246
249
|
|
247
250
|
o.bool *%w{-h --help}, '显示帮助'
|
248
251
|
o.bool *%w{-c --clear}, '清除本地账户信息'
|
249
252
|
o.bool *%w{-r --reset}, '重置账户信息'
|
253
|
+
o.string *%w{-l --log},'记录到指定的日志文件'
|
250
254
|
|
251
255
|
#院选课程 xxlx=4
|
252
256
|
o.bool *%w{-s --school}, '院选选课模式'
|
@@ -271,29 +275,29 @@ end
|
|
271
275
|
|
272
276
|
#error
|
273
277
|
exit unless opts
|
278
|
+
$logfile = opts[:log]
|
274
279
|
|
275
280
|
case true
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
puts opts
|
281
|
+
when opts.clear?
|
282
|
+
File.delete(TOKEN_FILE_NAME)
|
283
|
+
when opts.reset?
|
284
|
+
set_up_account
|
285
|
+
when opts.school?
|
286
|
+
select_school_elective(CLIENT)
|
287
|
+
when opts.general?
|
288
|
+
select_general_elective(CLIENT)
|
289
|
+
when opts.public?
|
290
|
+
select_public(CLIENT)
|
291
|
+
when opts.General?
|
292
|
+
select_general_required(CLIENT)
|
293
|
+
when opts.School?
|
294
|
+
select_school_required(CLIENT)
|
295
|
+
when opts.across?
|
296
|
+
select_across(CLIENT)
|
297
|
+
when opts.version?
|
298
|
+
puts Arb::Xmu::Course::VERSION
|
299
|
+
when opts.help?
|
300
|
+
puts(opts)
|
301
|
+
else
|
302
|
+
puts opts
|
299
303
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arb-xmu-course
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arybin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|