Commit b68b110b authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

TC parts tested

parent e8ee5a44
......@@ -72,15 +72,13 @@ class SQLTelecommands(TC):
name = 'Get TCs from db'
session = None
dbname = None
asn1SQLclasses = {}
def __init__(self, asn1_typename, parent=None):
''' Initialise the widget '''
super(SQLTelecommands, self).__init__(asn1_typename, parent)
# to do here = create a table widget, and place all the entries
# of the given ASN.1 type
if SQLTelecommands.session is None:
SQLTelecommands.session = SQLTelecommands.connect_to_db()
SQLTelecommands.session, SQLTelecommands.dbname = \
SQLTelecommands.connect_to_db()
self._asn1_typename = asn1_typename
typename_sql = asn1_typename + "_SQL"
self._asn1_klass = globals().get(typename_sql, None)
......@@ -94,12 +92,11 @@ class SQLTelecommands(TC):
connect to the DB and return a session object.'''
try:
config_info = open("sql_db/db.info").readlines()
sqlalchemy_url, dbname = config_info[0], config_info[1]
sqlalchemy_url, dbname = config_info[0].strip(), config_info[1].strip()
except:
print "The sql_db/db.info is either missing or invalid!"
print "Aborting..."
sys.exit(1)
SQLTelecommands.dbname = dbname
os.chdir("sql_db")
for key, val in vars(__import__(dbname + "_model")).iteritems():
if key not in globals():
......@@ -111,7 +108,7 @@ class SQLTelecommands(TC):
from sqlalchemy.orm import sessionmaker
SessionFactory = sessionmaker(bind=engine)
session = SessionFactory()
return session
return session, dbname
@staticmethod
def applicable():
......@@ -120,20 +117,24 @@ class SQLTelecommands(TC):
def getPageIndexes(self, offset, number):
return [
x.asn1
for x in SQLTelecommands.session.query(
self._asn1_klass
x
for x, in SQLTelecommands.session.query(
self._asn1_klass.iid
).filter(
self._asn1_klass.iid.between(offset, offset + number)
)
]
def sql2asn1(self, idx):
return SQLTelecommands.session.query(
row = SQLTelecommands.session.query(
self._asn1_klass
).filter(
self._asn1_klass.iid == idx
).first()
if row is not None:
return row.asn1
else:
return None
def onUpdateButtonClick(self, lineNb):
''' When user clicks on Update, the content of the selected TC will
......@@ -178,5 +179,7 @@ class SQLTelemetries(TM):
return True
if __name__ == '__main__':
print 'This module can only be imported from the main TASTE guis'
sys.exit(-1)
# print 'This module can only be imported from the main TASTE guis'
# sys.exit(-1)
a = SQLTelecommands('MyInteger_SQL')
print(a)
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