Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
79dd1f80
Commit
79dd1f80
authored
Aug 21, 2014
by
Penom Nom
Browse files
get informations from application.properties file
parent
67696790
Changes
1
Show whitespace changes
Inline
Side-by-side
bin/ng6_update_storage_size.py
View file @
79dd1f80
...
@@ -15,15 +15,10 @@
...
@@ -15,15 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
import
argparse
,
os
import
argparse
,
os
,
sys
from
ConfigParser
import
ConfigParser
from
MySQLdb
import
*
from
MySQLdb
import
*
def
existing_dir
(
path
):
if
os
.
path
.
isdir
(
path
):
return
path
else
:
raise
argparse
.
ArgumentTypeError
(
"Path '"
+
path
+
"' must be an existing directory"
)
def
get_storage_size
(
start_path
):
def
get_storage_size
(
start_path
):
total_size
=
0
total_size
=
0
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
start_path
):
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
start_path
):
...
@@ -48,14 +43,21 @@ def update_storage_size(savedir, host, user, passwd, db):
...
@@ -48,14 +43,21 @@ def update_storage_size(savedir, host, user, passwd, db):
conn
.
commit
()
conn
.
commit
()
curs
.
close
()
curs
.
close
()
print
"Updated database "
+
db
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"update analysis and run storage size in ng6 database"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"update analysis and run storage size in ng6 database"
)
parser
.
add_argument
(
"--savedir"
,
help
=
"ng6 data save directory"
,
required
=
True
,
type
=
existing_dir
)
parser
.
parse_args
()
parser
.
add_argument
(
"--host"
,
help
=
"hostname"
,
required
=
True
)
parser
.
add_argument
(
"--user"
,
help
=
"username"
,
required
=
True
)
ng6reader
=
ConfigParser
()
parser
.
add_argument
(
"--passwd"
,
help
=
"password for db connection"
,
required
=
True
)
ng6reader
.
read
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
,
"application.properties"
))
parser
.
add_argument
(
"--db"
,
help
=
"ng6 database name"
,
required
=
True
)
db_host
=
ng6reader
.
get
(
'database'
,
'host'
)
args
=
vars
(
parser
.
parse_args
())
db_user
=
ng6reader
.
get
(
'database'
,
'user'
)
db_password
=
ng6reader
.
get
(
'database'
,
'passwd'
)
update_storage_size
(
args
[
'savedir'
],
args
[
'host'
],
args
[
'user'
],
args
[
'passwd'
],
args
[
'db'
])
db_name
=
ng6reader
.
get
(
'database'
,
'dbname'
)
\ No newline at end of file
savedir
=
ng6reader
.
get
(
'storage'
,
'save_directory'
)
if
not
os
.
path
.
isdir
(
savedir
):
sys
.
exit
(
"Directory '"
+
savedir
+
"' does not exists. Pleache change your application.properties file"
)
update_storage_size
(
savedir
,
db_host
,
db_user
,
db_password
,
db_name
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment