Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61345864
__init__.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 6, 02:31
Size
3 KB
Mime Type
text/x-python
Expires
Wed, May 8, 02:31 (2 d)
Engine
blob
Format
Raw Data
Handle
17498752
Attached To
rPHAPI Phabricator API scripts
__init__.py
View Options
# -*- coding: utf-8 -*-
'''
@package getmystuph
@file __init__.py
@copyright BSD
@author Nicolas Richart <nicolas.richart@epfl.ch>
@section COPYRIGHT
Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne)
SCITAS - Scientific IT and Application Support
This file is part of getmystuph
'''
import
sys
as
__gms_sys
def
export
(
definition
):
"""
Decorator to export definitions from sub-modules to the top-level package
:param definition: definition to be exported
:return: definition
"""
__module
=
__gms_sys
.
modules
[
definition
.
__module__
]
__pkg
=
__gms_sys
.
modules
[
__module
.
__package__
]
__pkg
.
__dict__
[
definition
.
__name__
]
=
definition
if
'__all__'
not
in
__pkg
.
__dict__
:
__pkg
.
__dict__
[
'__all__'
]
=
[]
__pkg
.
__all__
.
append
(
definition
.
__name__
)
return
definition
try
:
from
termcolor
import
colored
except
ImportError
:
# noinspection PyUnusedLocal
def
colored
(
string
,
*
args
,
**
kwargs
):
return
string
__all__
=
[
'colored'
]
from
.
import
directory
from
.
import
repo
from
.
import
directory_backends
from
.
import
repo_backends
from
.
import
epfl
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
from
.utils
import
_register_backend
_register_backend
(
'c4science'
,
{
'git'
:
{
'module'
:
'repo_backends.phabricator'
,
'class'
:
'PhabRepo'
},
'svn'
:
{
'module'
:
'repo_backends.phabricator'
,
'class'
:
'PhabRepo'
},
'directory'
:
{
'module'
:
'directory_backends.phabricator'
,
'class'
:
'PhabDirectory'
}
})
def
get_password
(
service
,
username
,
keyring
=
None
):
service
=
'getmystuph/'
+
service
if
keyring
:
_print_service
=
colored
(
'{0}@{1}'
.
format
(
username
,
service
),
'blue'
)
_logger
.
debug
(
'Try to retrieve password from keyring
\'
{0}
\'
'
.
format
(
_print_service
))
# noqa: E501
keyring_passwd
=
keyring
.
get_password
(
service
,
username
)
if
keyring_passwd
is
None
:
_logger
.
debug
(
'Password for
\'
{0}
\'
not in keyring'
.
format
(
_print_service
))
# noqa: E501
keyring_passwd
=
getpass
.
getpass
(
"Password for {0}@{1}: "
.
format
(
username
,
service
))
store
=
ask_question
(
"Do you want to store your password "
+
"in the system keyring ?"
)
if
store
:
_logger
.
debug
(
'Adding password for
\'
{0}
\'
in keyring'
.
format
(
_print_service
))
# noqa: E501
self
.
_keyring
.
set_password
(
service
,
username
,
keyring_passwd
)
else
:
_logger
.
warning
(
'To avoid this message to reappear, '
+
'remove the
\'
use_keyring
\'
from the '
+
'configuration file.'
)
else
:
_logger
.
debug
(
'Password for
\'
{0}
\'
found in keyring'
.
format
(
_print_service
))
# noqa: E501
return
keyring_passwd
else
:
getpass_passwd
=
getpass
.
getpass
(
"Password for {0}@{1}: "
.
format
(
username
,
service
))
return
getpass_passwd
Event Timeline
Log In to Comment