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

Commit 79dd1f80 authored by Penom Nom's avatar Penom Nom

get informations from application.properties file

parent 67696790
......@@ -15,15 +15,10 @@
# 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 *
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):
......@@ -48,14 +43,21 @@ def update_storage_size(savedir, host, user, passwd, db):
conn.commit()
curs.close()
print "Updated database " + db
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())
parser.parse_args()
ng6reader = ConfigParser()
ng6reader.read(os.path.join(os.path.dirname(__file__), "..", "application.properties"))
db_host = ng6reader.get('database', 'host')
db_user = ng6reader.get('database', 'user')
db_password = ng6reader.get('database', 'passwd')
db_name = ng6reader.get('database', 'dbname')
savedir = ng6reader.get('storage', 'save_directory')
update_storage_size(args['savedir'], args['host'], args['user'], args['passwd'], args['db'])
\ No newline at end of file
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
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