Maintenance - Mise à jour mensuelle Lundi 6 Avril 2020 entre 7h00 et 9h00

Commit 67696790 authored by Penom Nom's avatar Penom Nom

update storage size

parent 74b74a09
#
# 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
......@@ -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 files</button>
{/if}
</div>
</div>
......
......@@ -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 files</button>
{/if}
</div>
......
......@@ -1846,7 +1846,7 @@ function addFileHandler( event ){
parameters["metadata"] = [];
parameters["admin_login"] = $("#user_login").val();
$('#wfForm').wfform({
workflowClass: "AddFile",
workflowClass: "AddFiles",
displayRunButton: false,
displayResetButton: false,
parameters: parameters,
......
......@@ -23,7 +23,7 @@ from ng6.project import Project
from ng6.run import Run
from ng6.analysis import Analysis
class AddFile (BasicNG6Workflow):
class AddFiles (BasicNG6Workflow):
def process(self):
# check if files provided exists
......
......@@ -16,8 +16,8 @@
#
[global]
name = addfile
description = add file to an existing analysis or run
name = addfiles
description = add files to an existing analysis or run
#
# Parameter section
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment