Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
021bae58
Commit
021bae58
authored
4 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[dav] Simplify configuration handling to make it generic for other tasks
parent
fea1a0b3
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!194
Allows extra pip-installable packages to be installed in every newly created environment
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/devtools/dav.py
+24
-33
24 additions, 33 deletions
bob/devtools/dav.py
with
24 additions
and
33 deletions
bob/devtools/dav.py
+
24
−
33
View file @
021bae58
...
@@ -10,6 +10,7 @@ from distutils.version import StrictVersion
...
@@ -10,6 +10,7 @@ from distutils.version import StrictVersion
import
dateutil.parser
import
dateutil.parser
from
.deploy
import
_setup_webdav_client
from
.deploy
import
_setup_webdav_client
from
.config
import
read_config
from
.log
import
echo_normal
from
.log
import
echo_normal
from
.log
import
echo_warning
from
.log
import
echo_warning
from
.log
import
get_logger
from
.log
import
get_logger
...
@@ -21,41 +22,31 @@ def _get_config():
...
@@ -21,41 +22,31 @@ def _get_config():
"""
Returns a dictionary with server parameters, or ask them to the user
"""
"""
Returns a dictionary with server parameters, or ask them to the user
"""
# tries to figure if we can authenticate using a configuration file
# tries to figure if we can authenticate using a configuration file
cfgs
=
[
"
~/.bdtrc
"
]
data
=
read_config
()
cfgs
=
[
os
.
path
.
expanduser
(
k
)
for
k
in
cfgs
]
for
k
in
cfgs
:
# this does some sort of validation for the "webdav" data...
if
os
.
path
.
exists
(
k
):
if
"
webdav
"
in
data
:
data
=
configparser
.
ConfigParser
()
if
(
"
server
"
not
in
data
[
"
webdav
"
]
data
.
read
(
k
)
if
(
"
webdav
"
not
in
data
or
"
server
"
not
in
data
[
"
webdav
"
]
or
"
username
"
not
in
data
[
"
webdav
"
]
or
"
username
"
not
in
data
[
"
webdav
"
]
or
"
password
"
not
in
data
[
"
webdav
"
]
or
"
password
"
not
in
data
[
"
webdav
"
]
):
):
assert
KeyError
,
(
raise
KeyError
(
"
The file %s should contain a single
"
f
"
If the configuration file
{
k
}
contains a
\"
webdav
\"
"
\
'"
webdav
"
section with 3 variables defined inside:
'
f
"
section, it should contain 3 variables defined inside:
"
\
'"
server
"
,
"
username
"
,
"
password
"
.
'
%
(
k
,)
f
'"
server
"
,
"
username
"
,
"
password
"
.
'
)
)
return
data
[
"
webdav
"
]
else
:
# ask the user for the information, in case nothing available
# ask the user for the information, cache credentials for future use
logger
.
warn
(
"
Requesting server information for webDAV operation.
"
\
retval
=
dict
()
"
(To create a configuration file, and avoid these, follow
"
\
retval
[
"
server
"
]
=
input
(
"
The base address of the server:
"
)
"
the Setup subsection at our Installation manual.)
"
)
retval
[
"
username
"
]
=
input
(
"
Username:
"
)
webdav_data
=
dict
()
retval
[
"
password
"
]
=
input
(
"
Password:
"
)
webdav_data
[
"
server
"
]
=
input
(
"
The base address of the server:
"
)
webdav_data
[
"
username
"
]
=
input
(
"
Username:
"
)
# record file for the user
webdav_data
[
"
password
"
]
=
input
(
"
Password:
"
)
data
=
configparser
.
ConfigParser
()
data
[
"
webdav
"
]
=
webdav_data
data
[
"
webdav
"
]
=
retval
with
open
(
cfgs
[
0
],
"
w
"
)
as
f
:
return
data
[
"
webdav
"
]
logger
.
warn
(
'
Recorded
"
%s
"
configuration file for next queries
'
)
data
.
write
(
f
)
os
.
chmod
(
cfgs
[
0
],
0o600
)
logger
.
warn
(
'
Changed mode of
"
%s
"
to be read-only to you
'
)
return
retval
def
setup_webdav_client
(
private
):
def
setup_webdav_client
(
private
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment