superbot 0.1.11 → 0.1.12
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/Gemfile.lock +1 -1
- data/lib/superbot/cli/root_command.rb +4 -1
- data/lib/superbot/cli/teleport_command.rb +5 -0
- data/lib/superbot/version.rb +1 -1
- data/lib/superbot/web.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9130be23f8c384feeb29aad1623e0c08ecedb5441549699040c8a8d9b708f1bc
|
4
|
+
data.tar.gz: 6eb48db3777f14e3838efdf3ba6dbbb2d51612445d536a6fee1772246f937a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4facd70408337b5f902820c46cd600b5605b819107372272874cb5e69bff60c5f094fb1c0b4a5f2f76cd676282d5c48404aac042a3a7ec8529670dc9e5f9c65a
|
7
|
+
data.tar.gz: b607d07c9e60828908dcfc8141926e118eae9863c52ada868e32bc3107a05449a9902e0b81673398c3abcbb96c1dc71333bb209996027cf0b081b6545dac53cd
|
data/Gemfile.lock
CHANGED
@@ -15,9 +15,12 @@ module Superbot
|
|
15
15
|
exit(0)
|
16
16
|
end
|
17
17
|
|
18
|
-
subcommand ["new"], "Create a new project", NewCommand
|
19
18
|
subcommand ["version"], "Show version information", VersionCommand
|
20
19
|
subcommand ["teleport"], "Open a teleport for superbots", TeleportCommand
|
20
|
+
if ENV['SUPERBOT_FEAT_PROJECT'] == 'true'
|
21
|
+
subcommand ["new"], "Create a new project", NewCommand
|
22
|
+
subcommand ["run"], "Run a project", RunCommand
|
23
|
+
end
|
21
24
|
|
22
25
|
def self.run
|
23
26
|
super
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "superbot/cloud/cli/cloud/validations"
|
4
|
+
|
3
5
|
module Superbot
|
4
6
|
module CLI
|
5
7
|
class TeleportCommand < Clamp::Command
|
6
8
|
include Superbot::Validations
|
9
|
+
include Superbot::Cloud::Validations
|
7
10
|
|
8
11
|
option ['--browser'], 'BROWSER', "Browser type to use. Can be either local or cloud", default: 'cloud' do |browser|
|
9
12
|
validates_browser_type browser
|
@@ -11,6 +14,8 @@ module Superbot
|
|
11
14
|
option ['--region'], 'REGION', 'Region for remote webdriver'
|
12
15
|
|
13
16
|
def execute
|
17
|
+
require_login unless browser == 'local'
|
18
|
+
|
14
19
|
@web = Superbot::Web.new(webdriver_type: browser, region: region)
|
15
20
|
@web.run_async_after_running!
|
16
21
|
|
data/lib/superbot/version.rb
CHANGED
data/lib/superbot/web.rb
CHANGED
@@ -62,7 +62,7 @@ module Superbot
|
|
62
62
|
headers instance.all_headers(response)
|
63
63
|
response.body
|
64
64
|
rescue StandardError => e
|
65
|
-
error_message = "Remote webdriver doesn't
|
65
|
+
error_message = "Remote webdriver doesn't respond"
|
66
66
|
puts error_message, e
|
67
67
|
halt 500, { message: error_message }.to_json
|
68
68
|
end
|
@@ -99,6 +99,8 @@ module Superbot
|
|
99
99
|
Net::HTTP.new(uri.hostname, uri.port).start do |http|
|
100
100
|
http.read_timeout = Superbot.cloud_timeout
|
101
101
|
http.request(req)
|
102
|
+
end.tap do |response|
|
103
|
+
output_response_errors(response)
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
@@ -122,6 +124,15 @@ module Superbot
|
|
122
124
|
request.env.map { |header, value| [header[5..-1].split("_").map(&:capitalize).join('-'), value] if header.start_with?("HTTP_") }.compact.to_h
|
123
125
|
end
|
124
126
|
|
127
|
+
def output_response_errors(response)
|
128
|
+
return unless response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
|
129
|
+
|
130
|
+
parsed_body = JSON.parse(response.body, symbolize_names: true)
|
131
|
+
puts "Error: #{parsed_body[:error]}"
|
132
|
+
rescue JSON::ParserError
|
133
|
+
puts "Request to webdriver failed with status: #{response.code}"
|
134
|
+
end
|
135
|
+
|
125
136
|
def run!
|
126
137
|
@sinatra.run_async!
|
127
138
|
end
|