phoseum-cli 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/phoseum-cli +31 -8
- data/lib/phoseum/phoseum-cli-lib.rb +19 -6
- 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: 7282f4986b7a9f813c002c354d5fae25c6b0e29fd6274c4cd8ee5fa2a75cc89b
|
4
|
+
data.tar.gz: 3e22b900db8134c6a90b9cd54c55d672ddef8af86195c0148f7458fe924d47c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f23596ae34b88ba0bbb537672304490c2e065e448dfbb9b434052f73dc73080c0dbe89cbbf9b2b149c844b8a5695be19472f669e91fbeaf90e6a89cbe5d773c
|
7
|
+
data.tar.gz: c044c7b0922aacc1f0830e0592f6b7357266664f9c4ecbc5418a69ad2e86cb0f20cec3067708aa0e3321e76c2b8f5d0c096bdf494717813866e55007eda83ce0
|
data/bin/phoseum-cli
CHANGED
@@ -108,6 +108,7 @@ def upload(album)
|
|
108
108
|
else
|
109
109
|
puts "\n#{msg_resp['error']}".red
|
110
110
|
error += 1
|
111
|
+
break
|
111
112
|
end
|
112
113
|
rescue
|
113
114
|
puts "\nThe server sent out an Error:".red
|
@@ -323,8 +324,9 @@ end
|
|
323
324
|
|
324
325
|
def delete(what='',path='')
|
325
326
|
puts "You must write 'YES' to confirm, otherwise NO is assumed".yellow
|
326
|
-
print "Are you sure you want to delete the
|
327
|
+
print "Are you sure you want to delete the #{what} #{path} :[YES/NO]: "
|
327
328
|
confirm=STDIN.gets.chomp
|
329
|
+
|
328
330
|
if confirm == "YES"
|
329
331
|
headers={}
|
330
332
|
if $config['TOKEN']
|
@@ -349,9 +351,20 @@ def delete(what='',path='')
|
|
349
351
|
) do |http|
|
350
352
|
http.request(request)
|
351
353
|
end
|
352
|
-
|
353
|
-
|
354
|
-
|
354
|
+
begin
|
355
|
+
list = JSON.parse(response.body)
|
356
|
+
if list['error']
|
357
|
+
puts list['error'].red
|
358
|
+
exit 1
|
359
|
+
else
|
360
|
+
puts list['success'].green
|
361
|
+
exit 0
|
362
|
+
end
|
363
|
+
rescue
|
364
|
+
puts "\nThe server sent out an Error:".red
|
365
|
+
puts clean_html(response.body)
|
366
|
+
exit 1
|
367
|
+
end
|
355
368
|
else
|
356
369
|
puts "Deleting cancelled.".green
|
357
370
|
end
|
@@ -388,12 +401,22 @@ case options
|
|
388
401
|
if options[:album]
|
389
402
|
value=check_string_sanity(options[:album])
|
390
403
|
what='album'
|
404
|
+
if value == "/" or value == '' or value.nil?
|
405
|
+
puts "It is Not possible to delete base album".red
|
406
|
+
exit 1
|
407
|
+
end
|
391
408
|
end
|
392
|
-
if
|
393
|
-
|
394
|
-
|
409
|
+
if options[:image]
|
410
|
+
if _found = check_image_exists(options[:image])
|
411
|
+
img_data = JSON.parse(_found)
|
412
|
+
value="#{img_data['web_path']}/#{img_data['image']}"
|
413
|
+
what='image'
|
414
|
+
else
|
415
|
+
puts "Image not found on server".red
|
416
|
+
exit 1
|
417
|
+
end
|
395
418
|
end
|
396
|
-
puts "Deleting
|
419
|
+
puts "Deleting #{what} #{value}".green if !$QUIET
|
397
420
|
delete(what,value)
|
398
421
|
when -> (u) { u[:upload] }
|
399
422
|
puts "Preparing to upload images to API server".green if !$QUIET
|
@@ -96,15 +96,13 @@ class String
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def client_checks
|
99
|
-
|
100
99
|
if $config['SERVERURL'] == ''
|
101
|
-
|
102
|
-
|
100
|
+
puts "I could not find a valid SERVERURL configuration. CFG is empty.".red
|
101
|
+
exit 1
|
103
102
|
elsif $config['SERVERURL'] !~ /\A#{URI::regexp(['https', 'http'])}\z/
|
104
103
|
puts "I could not find a valid SERVERURL configuration. Contains: #{$config['SERVERURL']}".red
|
105
104
|
exit 1
|
106
105
|
end
|
107
|
-
|
108
106
|
if !$config['DEFAULT_SECRET']
|
109
107
|
puts "I could not find the DEFAULT_SECRET from Phoseum config, this will limit our actions.".red
|
110
108
|
exit 1
|
@@ -132,7 +130,21 @@ def clean_html(msg)
|
|
132
130
|
return msg
|
133
131
|
end
|
134
132
|
|
135
|
-
def
|
133
|
+
def check_image_exists(fpath)
|
134
|
+
flocal = fpath.split('/')
|
135
|
+
filename = flocal.last
|
136
|
+
album = fpath.clone
|
137
|
+
album.gsub!(/#{filename}/,'')
|
138
|
+
|
139
|
+
if ffile = search_image(filename,album)
|
140
|
+
return ffile
|
141
|
+
else
|
142
|
+
return false
|
143
|
+
end
|
144
|
+
exit 0
|
145
|
+
end
|
146
|
+
|
147
|
+
def search_image(sign,album='')
|
136
148
|
headers = {}
|
137
149
|
if $config['TOKEN']
|
138
150
|
headers={ "bearer" => "#{$config['TOKEN']}" }
|
@@ -144,7 +156,7 @@ def search_image(sign)
|
|
144
156
|
exit 1
|
145
157
|
end
|
146
158
|
end
|
147
|
-
some_uri="?signature=#{sign}"
|
159
|
+
some_uri= album == '' ? "?signature=#{sign}" : "?signature=#{sign}&inside_album=#{album}"
|
148
160
|
base = URI.parse("#{$config['SERVERURL']}#{some_uri}")
|
149
161
|
request = Net::HTTP::Get.new(base,headers)
|
150
162
|
response = Net::HTTP.start(base.hostname, $config['PORT'],
|
@@ -158,6 +170,7 @@ def search_image(sign)
|
|
158
170
|
begin
|
159
171
|
list = JSON.parse(response.body)
|
160
172
|
if list['warning']
|
173
|
+
# puts list['warning']
|
161
174
|
return list['warning']
|
162
175
|
end
|
163
176
|
if list['success']
|