Commit cc2e2f09 authored by Olivier Sallou's avatar Olivier Sallou
Browse files

Merge pull request #1 from horkko/develop

Updates to get right production info
parents bda0987f ef2462e7
import os,sys
import os
import sys
import argparse
import pkg_resources
import datetime
import time
import logging
import re
import fnmatch
......@@ -14,14 +16,16 @@ from biomaj.config import BiomajConfig
from biomaj.workflow import UpdateWorkflow, RemoveWorkflow, Workflow
def migrate_bank(cur, bank):
cur.execute("SELECT path, session, creation, remove from productionDirectory WHERE ref_idbank="+str(bank['dbid']))
cur.execute("SELECT path, session, creation, remove, size from productionDirectory WHERE ref_idbank="+str(bank['dbid']))
bank['productionDirectory'] = []
for row in cur.fetchall():
if not row[3]:
'session': row[1], 'path': row[0],
'creation': row[2]
'path': row[0],
'session': row[1],
'creation': row[2],
'size': row[4],
for prod in bank['productionDirectory']:
if prod['session']:
cur.execute("SELECT ref_idupdateBank from session WHERE idsession="+str(prod['session']))
......@@ -40,8 +44,20 @@ def migrate_bank(cur, bank):
relmatch = pattern.match(release_dir)
if relmatch:
prod['release'] = prod['release']+'__'
# We create the session id from the productionDirectory.creation field
session_id = time.mktime(datetime.datetime.strptime(str(prod['creation']), "%Y-%m-%d %H:%M:%S").timetuple())
session_exists = False
b = Bank(bank['name'], no_log=True)
prod_present = False
# We check we did not already imported this session into the database
for s in['sessions']:
if s['id'] == session_id:
logging.warn('Session already imported: ' + + ':' + str(prod['creation']))
session_exists = True
if session_exists:
for p in['production']:
if p['release'] == prod['release']:
logging.warn('Prod release already imported: '":"+p['release'])
......@@ -51,9 +67,14 @@ def migrate_bank(cur, bank):
b.session.set('release', prod['release'])
b.session.set('remoterelease', prod['remoterelease'])
# Set production size from productionDirectory.size field
b.session.set('fullsize', prod['size'])
b.session._session['status'][Workflow.FLOW_OVER] = True
b.session._session['update'] = True
# We set the (timestamp) with creation field fron productionDirectory table
b.session.set('id', session_id)
# Listing files ?
root_files = []
if os.path.exists(prod['path']):
......@@ -75,9 +96,9 @@ def migrate_bank(cur, bank):
if os.path.lexists(current_link):['current'] = b.session._session['id']
'$set': {'current': b.session._session['id']}
'$set': {'current': b.session._session['id']}
def main():
Supports Markdown
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