Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ebulk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ebulk
Commits
b6c537b3
Commit
b6c537b3
authored
Jul 12, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix: credentials were requested more than one time
parent
c31993df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
29 deletions
+46
-29
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/dataset_utils.rb
.../embulk-wendelin-dataset-tool/lib/embulk/dataset_utils.rb
+35
-29
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/filelogger.rb
...ata/embulk-wendelin-dataset-tool/lib/embulk/filelogger.rb
+11
-0
No files found.
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/dataset_utils.rb
View file @
b6c537b3
...
@@ -132,35 +132,41 @@ class DatasetUtils
...
@@ -132,35 +132,41 @@ class DatasetUtils
end
end
def
getCredentials
(
tool_dir
)
def
getCredentials
(
tool_dir
)
credential_path
=
appendSlashTo
(
tool_dir
)
+
CREDENTIALS_FILE
# using logger because it's a singleton
if
File
.
exist?
(
credential_path
)
# TODO: refactor datase_utils to be a singleton and keep credentials in it
credentials
=
File
.
open
(
credential_path
).
read
.
chomp
.
split
(
RECORD_SEPARATOR
)
user
,
password
=
@logger
.
getCredentials
()
user
=
credentials
[
0
]
if
user
.
nil?
password
=
credentials
[
1
]
credential_path
=
appendSlashTo
(
tool_dir
)
+
CREDENTIALS_FILE
@logger
.
info
(
"Using stored credentials for user '
#{
user
}
'"
,
print
=
TRUE
)
if
File
.
exist?
(
credential_path
)
else
credentials
=
File
.
open
(
credential_path
).
read
.
chomp
.
split
(
RECORD_SEPARATOR
)
puts
user
=
credentials
[
0
]
puts
"Please, enter your ebulk user and password:"
password
=
credentials
[
1
]
puts
@logger
.
info
(
"Using stored credentials for user '
#{
user
}
'"
,
print
=
TRUE
)
puts
"** If you don't have a user, please feel free to register in the web site **"
else
puts
puts
@logger
.
info
(
"Remember that you can store your credentials for automatic authentication by running 'ebulk store-credentials'"
,
print
=
TRUE
)
puts
"Please, enter your ebulk user and password:"
puts
puts
print
"User:"
puts
"** If you don't have a user, please feel free to register in the web site **"
user
=
gets
.
chomp
puts
if
not
/^[A-Za-z][-A-Za-z0-9_]*$/
.
match
(
user
)
@logger
.
info
(
"Remember that you can store your credentials for automatic authentication by running 'ebulk store-credentials'"
,
print
=
TRUE
)
puts
puts
@logger
.
error
(
"Invalid user name. Did enter an invalid character?"
,
print
=
TRUE
)
print
"User:"
@logger
.
info
(
"Please enter a valid user name."
,
print
=
TRUE
)
user
=
gets
.
chomp
@logger
.
abortExecution
(
error
=
FALSE
)
if
not
/^[A-Za-z][-A-Za-z0-9_]*$/
.
match
(
user
)
puts
@logger
.
error
(
"Invalid user name. Did enter an invalid character?"
,
print
=
TRUE
)
@logger
.
info
(
"Please enter a valid user name."
,
print
=
TRUE
)
@logger
.
abortExecution
(
error
=
FALSE
)
end
print
"Password:"
password
=
STDIN
.
noecho
(
&
:gets
).
chomp
puts
puts
@logger
.
info
(
"Remember that you can store your credentials for automatic authentication by running 'ebulk store-credentials'"
,
print
=
TRUE
)
puts
sleep
1
end
end
print
"Password:"
@logger
.
setCredentials
(
user
,
password
)
password
=
STDIN
.
noecho
(
&
:gets
).
chomp
puts
puts
@logger
.
info
(
"Remember that you can store your credentials for automatic authentication by running 'ebulk store-credentials'"
,
print
=
TRUE
)
puts
sleep
1
end
end
return
user
,
password
return
user
,
password
end
end
...
@@ -814,7 +820,7 @@ class DatasetUtils
...
@@ -814,7 +820,7 @@ class DatasetUtils
renamed_dict
=
isRenamed
(
file_path
,
new_changed_files
,
file_dict
)
renamed_dict
=
isRenamed
(
file_path
,
new_changed_files
,
file_dict
)
if
renamed_dict
if
renamed_dict
changed_data_stream
=
{
"reference"
=>
reference
,
"id"
=>
new_changed_files
[
renamed_dict
[
"key"
]][
"id"
],
changed_data_stream
=
{
"reference"
=>
reference
,
"id"
=>
new_changed_files
[
renamed_dict
[
"key"
]][
"id"
],
"new_reference"
=>
new_changed_files
[
renamed_dict
[
"key"
]][
"reference"
],
"status"
=>
STATUS_RENAMED
,
"new_reference"
=>
new_changed_files
[
renamed_dict
[
"key"
]][
"reference"
],
"status"
=>
STATUS_RENAMED
,
"size"
=>
renamed_dict
[
"size"
],
"hash"
=>
renamed_dict
[
"hash"
]
}
"size"
=>
renamed_dict
[
"size"
],
"hash"
=>
renamed_dict
[
"hash"
]
}
new_changed_files
.
delete
(
renamed_dict
[
"key"
])
new_changed_files
.
delete
(
renamed_dict
[
"key"
])
end
end
...
...
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/filelogger.rb
View file @
b6c537b3
...
@@ -11,6 +11,8 @@ class LogManager
...
@@ -11,6 +11,8 @@ class LogManager
def
initialize
()
def
initialize
()
now
=
Time
.
now
.
strftime
(
"%d-%m-%Y"
)
now
=
Time
.
now
.
strftime
(
"%d-%m-%Y"
)
@filename
=
"
#{
now
.
to_s
}
.log"
@filename
=
"
#{
now
.
to_s
}
.log"
@user
@password
end
end
def
setFilename
(
tool_dir
,
prefix
)
def
setFilename
(
tool_dir
,
prefix
)
...
@@ -22,6 +24,15 @@ class LogManager
...
@@ -22,6 +24,15 @@ class LogManager
File
.
open
(
@path
,
'a'
)
{
|
file
|
file
.
puts
"------------------------------------------------"
+
"
\r\n
"
}
File
.
open
(
@path
,
'a'
)
{
|
file
|
file
.
puts
"------------------------------------------------"
+
"
\r\n
"
}
end
end
def
setCredentials
(
user
,
password
)
@user
=
user
@password
=
password
end
def
getCredentials
()
return
@user
,
@password
end
def
getLogPath
()
def
getLogPath
()
return
@path
return
@path
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment