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
ng6
Commits
67696790
Commit
67696790
authored
Aug 21, 2014
by
Penom Nom
Browse files
update storage size
parent
74b74a09
Changes
6
Hide whitespace changes
Inline
Side-by-side
bin/ng6_update_storage_size.py
0 → 100644
View file @
67696790
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
argparse
,
os
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
):
total_size
=
0
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
start_path
):
for
f
in
filenames
:
fp
=
os
.
path
.
join
(
dirpath
,
f
)
total_size
+=
os
.
path
.
getsize
(
fp
)
return
total_size
def
update_storage_size
(
savedir
,
host
,
user
,
passwd
,
db
):
conn
=
connect
(
host
,
user
,
passwd
,
db
)
with
conn
:
curs
=
conn
.
cursor
()
for
tablename
in
[
"tx_nG6_run"
,
"tx_nG6_analyze"
]
:
curs
.
execute
(
"SELECT uid, directory FROM "
+
tablename
)
res
=
curs
.
fetchall
()
update_list
=
[]
for
data
in
res
:
update_list
.
append
((
get_storage_size
(
savedir
+
data
[
1
]
),
data
[
0
])
)
curs
.
executemany
(
"UPDATE "
+
tablename
+
" SET storage_size='%s' WHERE uid= %s "
,
update_list
)
conn
.
commit
()
curs
.
close
()
if
__name__
==
"__main__"
:
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
.
add_argument
(
"--host"
,
help
=
"hostname"
,
required
=
True
)
parser
.
add_argument
(
"--user"
,
help
=
"username"
,
required
=
True
)
parser
.
add_argument
(
"--passwd"
,
help
=
"password for db connection"
,
required
=
True
)
parser
.
add_argument
(
"--db"
,
help
=
"ng6 database name"
,
required
=
True
)
args
=
vars
(
parser
.
parse_args
())
update_storage_size
(
args
[
'savedir'
],
args
[
'host'
],
args
[
'user'
],
args
[
'passwd'
],
args
[
'db'
])
\ No newline at end of file
ui/nG6/pi1/analyzes/BasicAnalyse.tpl
View file @
67696790
...
...
@@ -30,9 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<br/>
<div
style=
"float:right;
margin-right:25px
"
>
<div
style=
"float:right;"
>
{
if
$is_project_admin
}
<button
id=
"add_file"
type=
"button"
class=
"btn btn-small btn-primary"
><i
class=
"icon-plus icon-white"
></i>
add file
</button>
<button
id=
"add_file"
type=
"button"
class=
"btn btn-small btn-primary"
><i
class=
"icon-plus icon-white"
></i>
add file
s
</button>
{/
if
}
</div>
</div>
...
...
ui/nG6/pi1/run_view.tpl
View file @
67696790
...
...
@@ -63,9 +63,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{/
if
}
<br/>
<div
style=
"float:right;
margin-right:25px
"
>
<div
style=
"float:right;"
>
{
if
$runs
[
key
(
$runs
)].
is_admin
}
<button
id=
"add_file"
type=
"button"
class=
"btn btn-small btn-primary"
><i
class=
"icon-plus icon-white"
></i>
add file
</button>
<button
id=
"add_file"
type=
"button"
class=
"btn btn-small btn-primary"
><i
class=
"icon-plus icon-white"
></i>
add file
s
</button>
{/
if
}
</div>
...
...
ui/nG6/res/js/tx_nG6_pi1.js
View file @
67696790
...
...
@@ -1846,7 +1846,7 @@ function addFileHandler( event ){
parameters
[
"
metadata
"
]
=
[];
parameters
[
"
admin_login
"
]
=
$
(
"
#user_login
"
).
val
();
$
(
'
#wfForm
'
).
wfform
({
workflowClass
:
"
AddFile
"
,
workflowClass
:
"
AddFile
s
"
,
displayRunButton
:
false
,
displayResetButton
:
false
,
parameters
:
parameters
,
...
...
workflows/addfile/__init__.py
→
workflows/addfile
s
/__init__.py
View file @
67696790
...
...
@@ -23,7 +23,7 @@ from ng6.project import Project
from
ng6.run
import
Run
from
ng6.analysis
import
Analysis
class
AddFile
(
BasicNG6Workflow
):
class
AddFile
s
(
BasicNG6Workflow
):
def
process
(
self
):
# check if files provided exists
...
...
workflows/addfile/workflow.properties
→
workflows/addfile
s
/workflow.properties
View file @
67696790
...
...
@@ -16,8 +16,8 @@
#
[global]
name
=
addfile
description
=
add file to an existing analysis or run
name
=
addfile
s
description
=
add file
s
to an existing analysis or run
#
# Parameter section
...
...
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