phoseum-cli 0.0.4 → 0.0.5
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/lib/phoseum/phoseum-cli-lib.rb +48 -2
- 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: a37ca1ca918358760c52aeff733cb635c01843958a0f45c9d7ba36354abd6bc3
|
4
|
+
data.tar.gz: b3bf79b10605c1925fc8e2bcf71841de774e56a457e7518a16c86dfdad2af8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 274832a0b5d037a2363162702d02c450e2d25869d6b50ab9b91c89949902643413c321621e6ed654572dd2356ebe1444f8030869fab3b7aa356351c722ac3aba
|
7
|
+
data.tar.gz: fc7a1bc69fb62ed22d9763380262c65a37d195d0854a88f94052a8aad559ea019d8d88662659abe630caaff62a83be76aa9c5f622f8b0ff958a2b42436f2ce4d
|
@@ -32,6 +32,10 @@ def option_parser(opts)
|
|
32
32
|
options[:login] = l
|
33
33
|
end
|
34
34
|
|
35
|
+
opts.on("-m", "--multiple", "Ignore repeated images, keep multiple") do |m|
|
36
|
+
options[:multiple] = m
|
37
|
+
end
|
38
|
+
|
35
39
|
opts.on("-v", "--verbose", "Run verbosely (DEBUG mode)") do |v|
|
36
40
|
options[:verbose] = v
|
37
41
|
end
|
@@ -111,15 +115,57 @@ def client_checks
|
|
111
115
|
puts "I could not find the DEFAULT_SECRET from Phoseum config, Variable is empty.".red
|
112
116
|
exit 1
|
113
117
|
end
|
114
|
-
|
115
118
|
if !$config['SERVERURL']
|
116
119
|
puts "I could not find the SERVERURL from Phoseum config, this client is then useless.".red
|
117
120
|
exit 1
|
118
121
|
end
|
119
|
-
|
120
122
|
if !$config['PORT']
|
121
123
|
puts "I could not find the PORT from Phoseum config, this client is then useless.".red
|
122
124
|
exit 1
|
123
125
|
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def clean_html(msg)
|
129
|
+
msg.gsub!(/<\/?[^>]*>/, ' ')
|
130
|
+
msg.gsub!(/\n\n+/, '\n')
|
131
|
+
msg.gsub!(/^\n|\n$/, ' ')
|
132
|
+
return msg
|
133
|
+
end
|
124
134
|
|
135
|
+
def search_image(sign)
|
136
|
+
headers = {}
|
137
|
+
if $config['TOKEN']
|
138
|
+
headers={ "bearer" => "#{$config['TOKEN']}" }
|
139
|
+
else
|
140
|
+
if token = user_login()
|
141
|
+
headers = { "bearer" => token }
|
142
|
+
else
|
143
|
+
puts "Login Failed".red
|
144
|
+
exit 1
|
145
|
+
end
|
146
|
+
end
|
147
|
+
some_uri="?signature=#{sign}"
|
148
|
+
base = URI.parse("#{$config['SERVERURL']}#{some_uri}")
|
149
|
+
request = Net::HTTP::Get.new(base,headers)
|
150
|
+
response = Net::HTTP.start(base.hostname, $config['PORT'],
|
151
|
+
:timeout => $config['CALL_TIMEOUT'],
|
152
|
+
:use_ssl => base.scheme == "https",
|
153
|
+
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
|
154
|
+
:ca_file => $config['CA_TRUST']
|
155
|
+
) do |http|
|
156
|
+
http.request(request)
|
157
|
+
end
|
158
|
+
begin
|
159
|
+
list = JSON.parse(response.body)
|
160
|
+
if list['warning']
|
161
|
+
return list['warning']
|
162
|
+
end
|
163
|
+
if list['success']
|
164
|
+
return false
|
165
|
+
end
|
166
|
+
rescue
|
167
|
+
puts "\nThe server sent out an Error:".red
|
168
|
+
puts clean_html(response.body)
|
169
|
+
exit 1
|
170
|
+
end
|
125
171
|
end
|