cnvrg 0.9.6 → 0.9.7
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/cnvrg/cli.rb +4 -35
- data/lib/cnvrg/files.rb +46 -2
- data/lib/cnvrg/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: bf56dd631c9d7dc157c8f0fd13a3efaa57c172dc
|
4
|
+
data.tar.gz: 0df56325de293a1a26cd39210a29345f38e21b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b42ccdcd5d4775778c6009a4bd50acdf2ce730d25d62f0a8a28fc6900e34665877cb71fffcb306bc398a685a21f675c31da845cae4caaa8f01362e42bc347953
|
7
|
+
data.tar.gz: 6f3dc0c94c7fee54dd34aeb3e2e1affa618aff50e74dfb84a01fde238c7c43c1149a9edcf71c35def78501248a53e8eac96cc8f8a285ca0fd0f617e9a6f6f389
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -1730,10 +1730,6 @@ module Cnvrg
|
|
1730
1730
|
clone_resp = Project.clone_dir(slug, owner, project_name,git)
|
1731
1731
|
|
1732
1732
|
end
|
1733
|
-
|
1734
|
-
# idx_status = Project.new(project_home).generate_idx
|
1735
|
-
# log_message("Cloned project #{project_name} successfully", Thor::Shell::Color::GREEN)
|
1736
|
-
|
1737
1733
|
else
|
1738
1734
|
if (Dir.exists? project_name)
|
1739
1735
|
# project_name = "#{project_name}_#{rand(1 .. 5000000000)}"
|
@@ -2420,40 +2416,13 @@ module Cnvrg
|
|
2420
2416
|
log_start(__method__, args, options)
|
2421
2417
|
project_home = get_project_home
|
2422
2418
|
@project = Project.new(project_home)
|
2423
|
-
@files = Cnvrg::Files.new(@project.owner, @project.slug)
|
2424
|
-
|
2425
|
-
files
|
2426
|
-
|
2427
|
-
log_message("No files to download", Thor::Shell::Color::RED)
|
2428
|
-
return
|
2429
|
-
end
|
2430
|
-
|
2431
|
-
begin
|
2432
|
-
if files["keys"].blank?
|
2433
|
-
log_message("No New files to download", Thor::Shell::Color::GREEN)
|
2434
|
-
return
|
2435
|
-
end
|
2436
|
-
progressbar = ProgressBar.create(:title => "Download Progress",
|
2437
|
-
:progress_mark => '=',
|
2438
|
-
:format => "%b>>%i| %p%% %t",
|
2439
|
-
:starting_at => 0,
|
2440
|
-
:total => files['keys'].size,
|
2441
|
-
:autofinish => true)
|
2442
|
-
download_result = @files.download_multpile_files_s3(files, project_home, progress: progressbar)
|
2443
|
-
if download_result
|
2444
|
-
progressbar.finish
|
2445
|
-
log_message("Done.\nDownloaded finished successfully", Thor::Shell::Color::GREEN)
|
2446
|
-
else
|
2447
|
-
log_message("Error while trying to download\n", Thor::Shell::Color::RED)
|
2448
|
-
|
2449
|
-
end
|
2450
|
-
|
2451
|
-
rescue => e
|
2419
|
+
@files = Cnvrg::Files.new(@project.owner, @project.slug, project: @project, cli: self, options: options)
|
2420
|
+
commit_sha1 = commit_sha1.try(:first) if commit_sha1.is_a? Array
|
2421
|
+
@files.download_commit(commit_sha1)
|
2422
|
+
rescue => e
|
2452
2423
|
log_error(e)
|
2453
2424
|
log_message("Error while trying to download ", Thor::Shell::Color::RED)
|
2454
2425
|
return
|
2455
|
-
end
|
2456
|
-
|
2457
2426
|
end
|
2458
2427
|
end
|
2459
2428
|
|
data/lib/cnvrg/files.rb
CHANGED
@@ -12,11 +12,33 @@ module Cnvrg
|
|
12
12
|
|
13
13
|
attr_reader :base_resource
|
14
14
|
|
15
|
-
def initialize(owner, project_slug, project_home: '')
|
15
|
+
def initialize(owner, project_slug, project_home: '', project: nil, progressbar: nil, cli: nil, options: {})
|
16
16
|
@project_slug = project_slug
|
17
17
|
@owner = owner
|
18
18
|
@base_resource = "users/#{owner}/projects/#{project_slug}/"
|
19
19
|
@project_home = project_home.presence || Cnvrg::CLI.get_project_home
|
20
|
+
@project = project
|
21
|
+
@progressbar = progressbar
|
22
|
+
@custom_progess = false
|
23
|
+
@cli = cli
|
24
|
+
@options = options
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def download_commit(sha1)
|
29
|
+
response = @project.clone(false, sha1)
|
30
|
+
log_error("Cant download commit #{sha1}") unless Cnvrg::CLI.is_response_success response, false
|
31
|
+
commit_sha1 = response["result"]["commit"]
|
32
|
+
files = response["result"]["tree"].keys
|
33
|
+
log_progress("Downloading #{files.size} Files")
|
34
|
+
idx = {commit: commit_sha1, tree: response["result"]["tree"]}
|
35
|
+
@progressbar ||= create_progressbar(files.size, "Clone Progress")
|
36
|
+
download_files(files, commit_sha1, progress: @progressbar)
|
37
|
+
@progressbar.finish if @custom_progess
|
38
|
+
Project.verify_cnvrgignore_exist(@project_slug, false)
|
39
|
+
@project.set_idx(idx)
|
40
|
+
log("Done")
|
41
|
+
log("Downloaded #{files.size} files")
|
20
42
|
end
|
21
43
|
|
22
44
|
def get_upload_options(number_of_items: 0, progress: false)
|
@@ -649,12 +671,14 @@ module Cnvrg
|
|
649
671
|
end
|
650
672
|
|
651
673
|
def create_progressbar(length = 10, title = 'Progress')
|
652
|
-
ProgressBar.create(:title => title,
|
674
|
+
@progressbar = ProgressBar.create(:title => title,
|
653
675
|
:progress_mark => '=',
|
654
676
|
:format => "%b>>%i| %p%% %t",
|
655
677
|
:starting_at => 0,
|
656
678
|
:total => length,
|
657
679
|
:autofinish => true)
|
680
|
+
@custom_progess = true
|
681
|
+
@progressbar
|
658
682
|
end
|
659
683
|
|
660
684
|
def download_files(files, commit, postfix: '', progress: nil)
|
@@ -954,5 +978,25 @@ module Cnvrg
|
|
954
978
|
response = Cnvrg::API.request("#{base_resource}/commit/rollback", 'POST', {commit_sha1: commit_sha1})
|
955
979
|
Cnvrg::CLI.is_response_success(response, false)
|
956
980
|
end
|
981
|
+
private
|
982
|
+
def log(msgs, type: Thor::Shell::Color::GREEN)
|
983
|
+
return false if @cli.blank?
|
984
|
+
msgs = [msgs].flatten
|
985
|
+
msgs.each do |msg|
|
986
|
+
@cli.log_message(msg, type)
|
987
|
+
end
|
957
988
|
end
|
989
|
+
|
990
|
+
|
991
|
+
def log_error(msgs)
|
992
|
+
@cli.log_error(msgs) if @cli.present?
|
993
|
+
log(msgs, type: Thor::Shell::Color::RED)
|
994
|
+
end
|
995
|
+
|
996
|
+
def log_progress(msgs)
|
997
|
+
log(msgs, type: Thor::Shell::Color::BLUE)
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
|
1001
|
+
|
958
1002
|
end
|
data/lib/cnvrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-12-
|
12
|
+
date: 2018-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|