datahen 0.14.5 → 0.14.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datahen/cli.rb +4 -0
- data/lib/datahen/cli/account.rb +17 -0
- data/lib/datahen/cli/env_var.rb +2 -6
- data/lib/datahen/cli/job.rb +2 -3
- data/lib/datahen/cli/scraper.rb +15 -1
- data/lib/datahen/cli/scraper_job.rb +36 -3
- data/lib/datahen/client.rb +1 -1
- data/lib/datahen/client/account.rb +13 -0
- data/lib/datahen/client/auth_token.rb +1 -1
- data/lib/datahen/client/base.rb +1 -0
- data/lib/datahen/client/job.rb +12 -0
- data/lib/datahen/client/scraper.rb +12 -0
- data/lib/datahen/client/scraper_job.rb +12 -0
- data/lib/datahen/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3dc2db62e50655c78bb70aceac56a3f1fb3f8ec87d155c65bbaf4e521d10fc5
|
4
|
+
data.tar.gz: 57de5a7b0e9271dcfbb05d7ac22df37a127cd3c427e03d93bb448359b7d30edc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73888c3cabdb2c4f20371fff2f73294a71eb105a282ffff9e85ab675865fe1a7ffd8efb768cd8f0e82667158b6c249bbfef0f883088538dfc1c2c1fc4cdab527
|
7
|
+
data.tar.gz: e15616500c7994d3c537b42c38dd4965035f7ef825181053ad05ece46a42194d8574c322ec3f3e24121ca0c7aac2c4a9351cd93dff64814855500b04a536d61d
|
data/lib/datahen/cli.rb
CHANGED
@@ -16,6 +16,7 @@ require 'datahen/cli/parser'
|
|
16
16
|
require 'datahen/cli/seeder'
|
17
17
|
require 'datahen/cli/finisher'
|
18
18
|
require 'datahen/cli/env_var'
|
19
|
+
require 'datahen/cli/account'
|
19
20
|
|
20
21
|
|
21
22
|
|
@@ -41,5 +42,8 @@ module Datahen
|
|
41
42
|
|
42
43
|
desc "var SUBCOMMAND ...ARGS", "for environment variable related activities"
|
43
44
|
subcommand "var", EnvVar
|
45
|
+
|
46
|
+
desc "account SUBCOMMAND ...ARGS", "for account related activities"
|
47
|
+
subcommand "account", Account
|
44
48
|
end
|
45
49
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Datahen
|
2
|
+
class CLI < Thor
|
3
|
+
class Account < Thor
|
4
|
+
|
5
|
+
desc "profile", "displays the account applied profile"
|
6
|
+
long_desc <<-LONGDESC
|
7
|
+
Displays the account applied profile
|
8
|
+
LONGDESC
|
9
|
+
def profile()
|
10
|
+
client = Client::Account.new(options)
|
11
|
+
puts "#{client.profile()}"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/datahen/cli/env_var.rb
CHANGED
@@ -2,7 +2,7 @@ module Datahen
|
|
2
2
|
class CLI < Thor
|
3
3
|
class EnvVar < Thor
|
4
4
|
desc "list", "List environment variables on the account"
|
5
|
-
|
5
|
+
|
6
6
|
long_desc <<-LONGDESC
|
7
7
|
List all environment variables on the account.
|
8
8
|
LONGDESC
|
@@ -19,7 +19,7 @@ module Datahen
|
|
19
19
|
<name>: Var name can only consist of alphabets, numbers, underscores. Name must be unique to your account, otherwise it will be overwritten.\x5
|
20
20
|
<value>: Value of variable.\x5
|
21
21
|
LONGDESC
|
22
|
-
option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
|
22
|
+
option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
|
23
23
|
def set(name, value)
|
24
24
|
# puts "options #{options}"
|
25
25
|
client = Client::EnvVar.new(options)
|
@@ -38,10 +38,6 @@ module Datahen
|
|
38
38
|
puts "#{client.unset(name)}"
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
data/lib/datahen/cli/job.rb
CHANGED
@@ -6,10 +6,10 @@ module Datahen
|
|
6
6
|
"#{basename} #{@package_name} #{command.usage}"
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
9
|
desc "list", "gets a list of jobs"
|
11
10
|
option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
|
12
11
|
option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
|
12
|
+
option :status, type: :string, desc: 'Returns jobs with a certain status'
|
13
13
|
long_desc <<-LONGDESC
|
14
14
|
List scrape jobs.
|
15
15
|
LONGDESC
|
@@ -34,8 +34,7 @@ module Datahen
|
|
34
34
|
client = Client::JobStat.new(options)
|
35
35
|
puts "#{client.job_current_stats(job_id, options)}"
|
36
36
|
end
|
37
|
-
|
38
|
-
|
37
|
+
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
data/lib/datahen/cli/scraper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Datahen
|
2
2
|
class CLI < Thor
|
3
3
|
class Scraper < Thor
|
4
|
-
desc "list", "List scrapers"
|
5
4
|
|
5
|
+
desc "list", "List scrapers"
|
6
6
|
long_desc <<-LONGDESC
|
7
7
|
List all scrapers.
|
8
8
|
LONGDESC
|
@@ -29,6 +29,9 @@ module Datahen
|
|
29
29
|
option :cancel_current_job, type: :boolean, desc: 'Set true to cancel currently active job if scheduler starts. Default: false'
|
30
30
|
option :schedule, type: :string, desc: 'Set the schedule of the scraper to run. Must be in CRON format.'
|
31
31
|
option :timezone, type: :string, desc: "Set the scheduler's timezone. Must be in IANA Timezone format. Defaults to \"America/Toronto\""
|
32
|
+
option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
|
33
|
+
option :multiple_jobs, type: :boolean, desc: 'Set true to enable multiple jobs. Default: false'
|
34
|
+
option :max_job_count, type: :numeric, desc: 'Set a value to set max number of jobs available. Set -1 for unlimited. Default: 3'
|
32
35
|
def create(scraper_name, git_repository)
|
33
36
|
# puts "options #{options}"
|
34
37
|
client = Client::Scraper.new(options)
|
@@ -51,6 +54,9 @@ module Datahen
|
|
51
54
|
option :cancel_current_job, type: :boolean, desc: 'Set true to cancel currently active job if scheduler starts. Default: false'
|
52
55
|
option :schedule, type: :string, desc: 'Set the schedule of the scraper to run. Must be in CRON format.'
|
53
56
|
option :timezone, type: :string, desc: "Set the scheduler's timezone. Must be in IANA Timezone format. Defaults to \"America/Toronto\""
|
57
|
+
option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
|
58
|
+
option :multiple_jobs, type: :boolean, desc: 'Set true to enable multiple jobs. Default: false'
|
59
|
+
option :max_job_count, type: :numeric, desc: 'Set a value to set max number of jobs available. Set -1 for unlimited. Default: 3'
|
54
60
|
def update(scraper_name)
|
55
61
|
client = Client::Scraper.new(options)
|
56
62
|
puts "#{client.update(scraper_name, options)}"
|
@@ -175,6 +181,14 @@ module Datahen
|
|
175
181
|
end
|
176
182
|
end
|
177
183
|
|
184
|
+
desc "profile <scraper_name>", "displays the scraper applied profile"
|
185
|
+
long_desc <<-LONGDESC
|
186
|
+
Displays the account applied profile
|
187
|
+
LONGDESC
|
188
|
+
def profile(scraper_name)
|
189
|
+
client = Client::Scraper.new(options)
|
190
|
+
puts "#{client.profile(scraper_name)}"
|
191
|
+
end
|
178
192
|
|
179
193
|
desc "job SUBCOMMAND ...ARGS", "manage scrapers jobs"
|
180
194
|
subcommand "job", ScraperJob
|
@@ -26,6 +26,7 @@ module Datahen
|
|
26
26
|
LONGDESC
|
27
27
|
option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
|
28
28
|
option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
|
29
|
+
option :status, type: :string, desc: 'Returns jobs with a certain status'
|
29
30
|
def list(scraper_name)
|
30
31
|
client = Client::ScraperJob.new(options)
|
31
32
|
puts "#{client.all(scraper_name)}"
|
@@ -47,6 +48,21 @@ module Datahen
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
desc "delete <scraper_name>", "delete a scraper's current job"
|
52
|
+
long_desc <<-LONGDESC
|
53
|
+
Delete a scraper's current job
|
54
|
+
LONGDESC
|
55
|
+
option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
|
56
|
+
def delete(scraper_name)
|
57
|
+
if options[:job]
|
58
|
+
client = Client::Job.new(options)
|
59
|
+
puts "#{client.delete(options[:job])}"
|
60
|
+
else
|
61
|
+
client = Client::ScraperJob.new(options)
|
62
|
+
puts "#{client.delete(scraper_name)}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
desc "resume <scraper_name>", "resumes a scraper's current job"
|
51
67
|
long_desc <<-LONGDESC
|
52
68
|
Resumes a scraper's current job
|
@@ -64,16 +80,17 @@ module Datahen
|
|
64
80
|
|
65
81
|
desc "pause <scraper_name>", "pauses a scraper's current job"
|
66
82
|
long_desc <<-LONGDESC
|
67
|
-
|
83
|
+
Pauses a scraper's current job
|
68
84
|
LONGDESC
|
69
85
|
option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
|
86
|
+
option :force, :aliases => :f, type: :boolean, desc: 'Force a job to be paused from a done or cancelled status'
|
70
87
|
def pause(scraper_name)
|
71
88
|
if options[:job]
|
72
89
|
client = Client::Job.new(options)
|
73
|
-
puts "#{client.pause(options[:job])}"
|
90
|
+
puts "#{client.pause(options[:job], options)}"
|
74
91
|
else
|
75
92
|
client = Client::ScraperJob.new(options)
|
76
|
-
puts "#{client.pause(scraper_name)}"
|
93
|
+
puts "#{client.pause(scraper_name, options)}"
|
77
94
|
end
|
78
95
|
end
|
79
96
|
|
@@ -85,6 +102,7 @@ module Datahen
|
|
85
102
|
option :workers, :aliases => :w, type: :numeric, desc: 'Set how many standard workers to use. Scraper job must be restarted(paused then resumed, or cancelled then resumed) for it to take effect. Default: 1. '
|
86
103
|
option :browsers, type: :numeric, desc: 'Set how many browser workers to use. Scraper job must be restarted(paused then resumed, or cancelled then resumed) for it to take effect. Default: 0. '
|
87
104
|
option :proxy_type, desc: 'Set the Proxy type. Default: standard'
|
105
|
+
option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
|
88
106
|
option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
|
89
107
|
def update(scraper_name)
|
90
108
|
if options[:job]
|
@@ -96,6 +114,21 @@ module Datahen
|
|
96
114
|
end
|
97
115
|
end
|
98
116
|
|
117
|
+
desc "profile <scraper_name>", "displays a scraper's current job applied profile"
|
118
|
+
long_desc <<-LONGDESC
|
119
|
+
Displays a scraper's current job applied profile
|
120
|
+
LONGDESC
|
121
|
+
option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
|
122
|
+
def profile(scraper_name)
|
123
|
+
if options[:job]
|
124
|
+
client = Client::Job.new(options)
|
125
|
+
puts "#{client.profile(options[:job])}"
|
126
|
+
else
|
127
|
+
client = Client::ScraperJob.new(options)
|
128
|
+
puts "#{client.profile(scraper_name)}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
99
132
|
desc "var SUBCOMMAND ...ARGS", "for managing scraper's job variables"
|
100
133
|
subcommand "var", ScraperJobVar
|
101
134
|
|
data/lib/datahen/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "datahen/client/base"
|
2
|
+
require "datahen/client/account"
|
2
3
|
require "datahen/client/auth_token"
|
3
4
|
require "datahen/client/deploy_key"
|
4
5
|
require 'datahen/client/export'
|
@@ -24,7 +25,6 @@ require "datahen/client/job_var"
|
|
24
25
|
require "datahen/client/scraper_job_var"
|
25
26
|
require "datahen/client/job_finisher"
|
26
27
|
|
27
|
-
|
28
28
|
module Datahen
|
29
29
|
module Client
|
30
30
|
end
|
data/lib/datahen/client/base.rb
CHANGED
@@ -58,6 +58,7 @@ module Datahen
|
|
58
58
|
query[:limit] = opts[:limit] if opts[:limit]
|
59
59
|
query[:order] = opts[:order] if opts[:order]
|
60
60
|
query[:filter] = opts[:filter] if opts[:filter]
|
61
|
+
query[:force] = opts[:force] if opts[:force]
|
61
62
|
|
62
63
|
if opts[:query]
|
63
64
|
if opts[:query].is_a?(Hash)
|
data/lib/datahen/client/job.rb
CHANGED
@@ -20,6 +20,7 @@ module Datahen
|
|
20
20
|
body[:standard_worker_count] = opts[:workers] if opts[:workers]
|
21
21
|
body[:browser_worker_count] = opts[:browsers] if opts[:browsers]
|
22
22
|
body[:proxy_type] = opts[:proxy_type] if opts[:proxy_type]
|
23
|
+
body[:profile] = opts[:profile] if opts[:profile]
|
23
24
|
params = @options.merge({body: body.to_json})
|
24
25
|
|
25
26
|
self.class.put("/jobs/#{job_id}", params)
|
@@ -64,6 +65,17 @@ module Datahen
|
|
64
65
|
self.class.put("/jobs/#{job_id}/finisher_update", params)
|
65
66
|
end
|
66
67
|
|
68
|
+
def profile(job_id, opts={})
|
69
|
+
params = @options.merge(opts)
|
70
|
+
|
71
|
+
self.class.get("/jobs/#{job_id}/profile", params)
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete(job_id, opts={})
|
75
|
+
params = @options.merge(opts)
|
76
|
+
self.class.delete("/jobs/#{job_id}", params)
|
77
|
+
end
|
78
|
+
|
67
79
|
end
|
68
80
|
|
69
81
|
end
|
@@ -25,6 +25,9 @@ module Datahen
|
|
25
25
|
body[:cancel_current_job] = opts[:cancel_current_job] if opts[:cancel_current_job]
|
26
26
|
body[:schedule] = opts[:schedule] if opts[:schedule]
|
27
27
|
body[:timezone] = opts[:timezone] if opts[:timezone]
|
28
|
+
body[:profile] = opts[:profile] if opts[:profile]
|
29
|
+
body[:multiple_jobs] = opts[:multiple_jobs] if opts[:multiple_jobs]
|
30
|
+
body[:max_job_count] = opts[:max_job_count] if opts[:max_job_count]
|
28
31
|
params = @options.merge({body: body.to_json})
|
29
32
|
self.class.post("/scrapers", params)
|
30
33
|
end
|
@@ -43,6 +46,9 @@ module Datahen
|
|
43
46
|
body[:cancel_current_job] = opts[:cancel_current_job] if opts.has_key?("cancel_current_job") || opts.has_key?(:cancel_current_job)
|
44
47
|
body[:schedule] = opts[:schedule] if opts[:schedule]
|
45
48
|
body[:timezone] = opts[:timezone] if opts[:timezone]
|
49
|
+
body[:profile] = opts[:profile] if opts[:profile]
|
50
|
+
body[:multiple_jobs] = opts[:multiple_jobs] if opts.has_key?("multiple_jobs") || opts.has_key?(:multiple_jobs)
|
51
|
+
body[:max_job_count] = opts[:max_job_count] if opts.has_key?("max_job_count") || opts.has_key?(:max_job_count)
|
46
52
|
params = @options.merge({body: body.to_json})
|
47
53
|
|
48
54
|
self.class.put("/scrapers/#{scraper_name}", params)
|
@@ -52,6 +58,12 @@ module Datahen
|
|
52
58
|
params = @options.merge(opts)
|
53
59
|
self.class.delete("/scrapers/#{scraper_name}", params)
|
54
60
|
end
|
61
|
+
|
62
|
+
def profile(scraper_name, opts={})
|
63
|
+
params = @options.merge(opts)
|
64
|
+
|
65
|
+
self.class.get("/scrapers/#{scraper_name}/profile", params)
|
66
|
+
end
|
55
67
|
end
|
56
68
|
end
|
57
69
|
end
|
@@ -29,6 +29,7 @@ module Datahen
|
|
29
29
|
body[:standard_worker_count] = opts[:workers] if opts[:workers]
|
30
30
|
body[:browser_worker_count] = opts[:browsers] if opts[:browsers]
|
31
31
|
body[:proxy_type] = opts[:proxy_type] if opts[:proxy_type]
|
32
|
+
body[:profile] = opts[:profile] if opts[:profile]
|
32
33
|
params = @options.merge({body: body.to_json})
|
33
34
|
|
34
35
|
self.class.put("/scrapers/#{scraper_name}/current_job", params)
|
@@ -48,6 +49,17 @@ module Datahen
|
|
48
49
|
opts[:status] = 'paused'
|
49
50
|
update(scraper_name, opts)
|
50
51
|
end
|
52
|
+
|
53
|
+
def profile(scraper_name, opts={})
|
54
|
+
params = @options.merge(opts)
|
55
|
+
|
56
|
+
self.class.get("/scrapers/#{scraper_name}/current_job/profile", params)
|
57
|
+
end
|
58
|
+
|
59
|
+
def delete(scraper_name, opts={})
|
60
|
+
params = @options.merge(opts)
|
61
|
+
self.class.delete("/scrapers/#{scraper_name}/current_job", params)
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
53
65
|
end
|
data/lib/datahen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datahen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parama Danoesubroto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- exe/hen
|
190
190
|
- lib/datahen.rb
|
191
191
|
- lib/datahen/cli.rb
|
192
|
+
- lib/datahen/cli/account.rb
|
192
193
|
- lib/datahen/cli/env_var.rb
|
193
194
|
- lib/datahen/cli/finisher.rb
|
194
195
|
- lib/datahen/cli/global_page.rb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- lib/datahen/cli/scraper_var.rb
|
207
208
|
- lib/datahen/cli/seeder.rb
|
208
209
|
- lib/datahen/client.rb
|
210
|
+
- lib/datahen/client/account.rb
|
209
211
|
- lib/datahen/client/auth_token.rb
|
210
212
|
- lib/datahen/client/backblaze_content.rb
|
211
213
|
- lib/datahen/client/base.rb
|
@@ -264,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
266
|
- !ruby/object:Gem::Version
|
265
267
|
version: '0'
|
266
268
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
269
|
+
rubygems_version: 3.0.3
|
268
270
|
signing_key:
|
269
271
|
specification_version: 4
|
270
272
|
summary: DataHen toolbelt for developers
|