Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
D-GENIES
Commits
7b20cfc0
Commit
7b20cfc0
authored
Feb 14, 2018
by
Floreal Cabanettes
Browse files
Change application.properties location compatible for windows + setup.py
parent
b2860602
Changes
2
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
7b20cfc0
import
os
from
setuptools
import
setup
,
find_packages
from
pip.req
import
parse_requirements
...
...
@@ -6,15 +7,31 @@ install_reqs = parse_requirements('requirements.txt', session='hack')
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs
=
[
str
(
ir
.
req
)
for
ir
in
install_reqs
]
setup
(
name
=
'dgenies'
,
version
=
'0.9'
,
packages
=
find_packages
(
'src'
),
package_dir
=
{
'dgenies'
:
'src/dgenies'
},
include_package_data
=
True
,
zip_safe
=
False
,
install_requires
=
reqs
,
data_files
=
[(
'/etc/dgenies'
,
[
'application.properties'
]),
(
'/var/www/dgenies'
,
[
'dgenies.wsgi'
])],
scripts
=
[
'src/bin/dgenies'
],
)
if
os
.
name
==
"posix"
:
setup
(
name
=
'dgenies'
,
version
=
'0.9'
,
packages
=
find_packages
(
'src'
),
package_dir
=
{
'dgenies'
:
'src/dgenies'
},
include_package_data
=
True
,
zip_safe
=
False
,
install_requires
=
reqs
,
data_files
=
[(
'/etc/dgenies'
,
[
'application.properties'
]),
(
'/var/www/dgenies'
,
[
'dgenies.wsgi'
])],
scripts
=
[
'src/bin/dgenies'
],
)
else
:
setup
(
name
=
'dgenies'
,
version
=
'0.9'
,
packages
=
find_packages
(
'src'
),
package_dir
=
{
'dgenies'
:
'src/dgenies'
},
include_package_data
=
True
,
zip_safe
=
False
,
install_requires
=
reqs
,
data_files
=
[(
'.dgenies'
,
[
'application.properties'
])],
scripts
=
[
'src/bin/dgenies'
],
)
src/dgenies/config_reader.py
View file @
7b20cfc0
import
os
import
re
import
inspect
from
pathlib
import
Path
from
configparser
import
RawConfigParser
,
NoOptionError
,
NoSectionError
from
dgenies.lib.decorators
import
Singleton
...
...
@@ -11,9 +12,6 @@ class AppConfigReader:
Store all configs
"""
config_file
=
"/etc/dgenies/application.properties"
config_file_local
=
config_file
+
".local"
def
__init__
(
self
):
"""
All "get_*" functions results are stored in the "self.*" corresponding attribute
...
...
@@ -21,17 +19,19 @@ class AppConfigReader:
"""
self
.
app_dir
=
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
))
config_file
=
[]
if
os
.
path
.
exists
(
self
.
config_file
):
config_file
.
append
(
self
.
config_file
)
if
os
.
path
.
exists
(
self
.
config_file_local
):
config_file
.
append
(
self
.
config_file_local
)
if
len
(
config_file
)
>
0
:
self
.
config_file
=
config_file
else
:
config_file_search
=
[
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
sep
),
"dgenies"
,
"application.properties"
),
"/etc/dgenies/application.properties"
,
"/etc/dgenies/application.properties.local"
,
os
.
path
.
join
(
str
(
Path
.
home
()),
".dgenies"
,
"application.properties"
)]
for
my_config_file
in
config_file_search
:
if
os
.
path
.
exists
(
my_config_file
):
config_file
.
append
(
my_config_file
)
if
len
(
config_file
)
==
0
:
raise
FileNotFoundError
(
"ERROR: application.properties not found. Please copy the example file and "
"check properties are correct for you!"
)
self
.
reader
=
RawConfigParser
()
self
.
reader
.
read
(
self
.
config_file
)
self
.
reader
.
read
(
config_file
)
for
attr
in
dir
(
self
):
attr_o
=
getattr
(
self
,
attr
)
if
attr
.
startswith
(
"_get_"
)
and
callable
(
attr_o
):
...
...
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