From 04ccb73d99e0e90e924d0f8d926c7881833802c3 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 17 May 2016 16:52:51 -0600 Subject: [PATCH 01/18] update tests --- .travis.yml | 4 ++-- requirements.txt | 2 +- tests/test_controller/test_frmAddPoints.py | 4 ++-- tests/test_odmdata/test_FreeTDS.py | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3df53a..38a4570 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,6 +62,6 @@ install: # now just our code # command to run tests script: - - - py.test + - pythonw -m pytest +# - py.test diff --git a/requirements.txt b/requirements.txt index 75eb7ef..9bd5dab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ pymysql numpy scipy sqlalchemy -matplotlib +#matplotlib #psycopg2 #pandas #geoalchemy2 diff --git a/tests/test_controller/test_frmAddPoints.py b/tests/test_controller/test_frmAddPoints.py index 66bdc93..777efdb 100755 --- a/tests/test_controller/test_frmAddPoints.py +++ b/tests/test_controller/test_frmAddPoints.py @@ -101,8 +101,8 @@ def test_customRemove(self): ## Test order remains the same after removing size = 10000 objects = self._buildObjects(size) - for i in objects: - print i.dataValue + # for i in objects: + # print i.dataValue assert len(objects) == size tests = [1, 5, 25, 100, 150, 300, 600, 55, 9000] diff --git a/tests/test_odmdata/test_FreeTDS.py b/tests/test_odmdata/test_FreeTDS.py index ce032c1..de36ddb 100644 --- a/tests/test_odmdata/test_FreeTDS.py +++ b/tests/test_odmdata/test_FreeTDS.py @@ -16,7 +16,6 @@ def setup(self): if sys.platform != 'win32': # connection string # create engine - #quoted = urllib.quote_plus('DRIVER={FreeTDS};Server=iutahqc.uwrl.usu.edu;Database=iUTAH_Logan_OD;UID=qc;PWD=iUTAH123!!;TDS_Version=8.0;Port=1433;') quoted = urllib.quote_plus('DRIVER={FreeTDS};DSN=iutahqc;UID=qc;PWD=iUTAH123!!;') engine = sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect={}'.format(quoted)) # conn = engine.connect() @@ -37,6 +36,6 @@ def setup(self): print i assert q print engine - #todo: does this work on mac? - def test_connection(self): - pass + # + # def test_connection(self): + # pass From 0239db3572fd99fc19b5713dda068057fc9499bb Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 17 May 2016 17:24:24 -0600 Subject: [PATCH 02/18] test requirements.txt --- odmtools/odmservices/series_service.py | 1 + requirements_tests.txt | 11 +------- tests/test_odmservices/test_edit_service.py | 29 ++++++++++++++++----- tests/test_util.py | 1 + 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/odmtools/odmservices/series_service.py b/odmtools/odmservices/series_service.py index 891faae..c843fa7 100644 --- a/odmtools/odmservices/series_service.py +++ b/odmtools/odmservices/series_service.py @@ -744,6 +744,7 @@ def series_exists_quint(self, site_id, var_id, method_id, source_id, qcl_id): return True except: return False + def qcl_exists(self, q): """ diff --git a/requirements_tests.txt b/requirements_tests.txt index 2561a22..9d3c7d6 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,14 +1,5 @@ -#-r requirements.txt +-r requirements.txt -pyodbc -pymysql -numpy==1.9.2 -scipy -sqlalchemy -matplotlib==1.4.3 -#psycopg2 -#pandas -#geoalchemy2 diff --git a/tests/test_odmservices/test_edit_service.py b/tests/test_odmservices/test_edit_service.py index ded9805..a27ad13 100644 --- a/tests/test_odmservices/test_edit_service.py +++ b/tests/test_odmservices/test_edit_service.py @@ -74,19 +74,34 @@ def test_save_series(self): def test_save_as_series(self): var = test_util.add_variable(self.session) print var + stlen = len(self.series.data_values) assert self.edit_service.save_as(var= var) - ##assert self.edit_service.memDB.series_service.series_exists(self.series.site.id, var, self.series.method.id, - # self.series.source.id, self.series.qcl.id) + assert self.edit_service.memDB.series_service.series_exists_quint(self.series.site_id, var.id, self.series.method_id, self.series.source_id, self.series.quality_control_level_id) def test_save_as_existing_series(self): var = test_util.add_variable(self.session) assert self.edit_service.save_existing(var = var) - def test_save_append(self): - #TODO add custon test - var = test_util.add_variable(self.session) - print var - assert self.edit_service.save_existing(var= var) + # def test_save_append(self): + # #TODO add custon test + # var = test_util.add_variable(self.session) + # meth = test_util.add_method(self.session) + # + # print var + # print meth + # + # print self.series.value_count + # print len(self.series.data_values) + # # keep data from original series if overlap: + # result = self.edit_service.save_appending(var=var, overwrite = False) + # assert result + # + # print self.series.value_count + # print len(self.series.data_values) + # # keep new: + # result = self.edit_service.save_appending(var=var, overwrite = True) + # assert result + diff --git a/tests/test_util.py b/tests/test_util.py index 3e7c2d0..43789d3 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -95,6 +95,7 @@ def add_series(session): series.end_date_time = dvs[-1].local_date_time series.begin_date_time_utc = dvs[0].date_time_utc series.end_date_time_utc = dvs[-1].date_time_utc + series.value_count = len(dvs) session.add(series) session.commit() From 8d1241ba3720920efcd068ccff7921d29c34b595 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 17 May 2016 17:37:07 -0600 Subject: [PATCH 03/18] test requirements --- odmtools/odmservices/edit_service.py | 2 +- requirements.txt | 2 +- requirements_tests.txt | 3 -- tests/test_odmservices/test_edit_service.py | 39 +++++++++++---------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index e0699fb..f6a87ee3 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -510,7 +510,7 @@ def updateSeries(self, var=None, method=None, qcl=None, is_new_series=False, ove series.end_date_time = datetime.datetime.strptime(str(np.max(dvs["LocalDateTime"])), form) series.end_date_time_utc = datetime.datetime.strptime(str(np.max(dvs["DateTimeUTC"])), form) #TODO figure out how to calculate the new value count - series.value_count = series.value_count+len(dvs) + series.value_count = len(dvs) if overlap: if overwrite: diff --git a/requirements.txt b/requirements.txt index 9bd5dab..1aaf9bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ pyodbc pymysql numpy -scipy +#scipy sqlalchemy #matplotlib #psycopg2 diff --git a/requirements_tests.txt b/requirements_tests.txt index 9d3c7d6..0fbc0b9 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,8 +1,5 @@ -r requirements.txt - - - pytest pytest-cov mock diff --git a/tests/test_odmservices/test_edit_service.py b/tests/test_odmservices/test_edit_service.py index a27ad13..56ba043 100644 --- a/tests/test_odmservices/test_edit_service.py +++ b/tests/test_odmservices/test_edit_service.py @@ -82,25 +82,26 @@ def test_save_as_existing_series(self): var = test_util.add_variable(self.session) assert self.edit_service.save_existing(var = var) - # def test_save_append(self): - # #TODO add custon test - # var = test_util.add_variable(self.session) - # meth = test_util.add_method(self.session) - # - # print var - # print meth - # - # print self.series.value_count - # print len(self.series.data_values) - # # keep data from original series if overlap: - # result = self.edit_service.save_appending(var=var, overwrite = False) - # assert result - # - # print self.series.value_count - # print len(self.series.data_values) - # # keep new: - # result = self.edit_service.save_appending(var=var, overwrite = True) - # assert result + def test_save_append(self): + #TODO add custon test + + len1= len(self.series.data_values) + # keep data from original series if overlap: + result = self.edit_service.save_appending(overwrite = False) + len2= len(self.series.data_values) + assert len1 == len2 + + + # self.edit_service.memDB.updateValue([self.sdate],'+', 5 ) + # dvs = self.memory_db.getDataValuesDF() + # assert dvs["DataValue"][0] == 14 + # assert result + + print self.series.value_count + print len(self.series.data_values) + # keep new: + result = self.edit_service.save_appending(overwrite = True) + assert result From 7d4575a5adf45c436fa1946666454e325f7ce640 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 17 May 2016 17:46:17 -0600 Subject: [PATCH 04/18] add test for save_appending --- .travis.yml | 6 ++--- tests/test_odmservices/test_edit_service.py | 28 +++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38a4570..d7ee912 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,9 +43,9 @@ addons: # mariadb: '10.1' before_script: - - ./scripts/tests/mysql_setup.sh - - ./scripts/tests/postgres_setup.sh - - ./scripts/tests/freetds.sh + - ./tests/scripts/mysql_setup.sh + - ./tests/scripts/postgres_setup.sh + - ./tests/scripts/freetds.sh before_install: # python -m pip makes the install go into the virtualenv diff --git a/tests/test_odmservices/test_edit_service.py b/tests/test_odmservices/test_edit_service.py index 56ba043..2ba40e1 100644 --- a/tests/test_odmservices/test_edit_service.py +++ b/tests/test_odmservices/test_edit_service.py @@ -82,25 +82,33 @@ def test_save_as_existing_series(self): var = test_util.add_variable(self.session) assert self.edit_service.save_existing(var = var) - def test_save_append(self): + def test_save_append_keep(self): #TODO add custon test len1= len(self.series.data_values) # keep data from original series if overlap: + + + svalue = self.series.data_values[0] + + self.edit_service.memDB.updateValue([svalue.local_date_time],'+', 5 ) + news= self.edit_service.memDB.series_service.get_series_by_id(self.series.id) result = self.edit_service.save_appending(overwrite = False) len2= len(self.series.data_values) assert len1 == len2 + assert news.data_values[0].data_value == svalue.data_value + assert result + def test_save_append_overwrite(self): + len1= len(self.series.data_values) + svalue = self.series.data_values[0] - # self.edit_service.memDB.updateValue([self.sdate],'+', 5 ) - # dvs = self.memory_db.getDataValuesDF() - # assert dvs["DataValue"][0] == 14 - # assert result - - print self.series.value_count - print len(self.series.data_values) - # keep new: - result = self.edit_service.save_appending(overwrite = True) + self.edit_service.memDB.updateValue([svalue.local_date_time],'+', 5 ) + news= self.edit_service.memDB.series_service.get_series_by_id(self.series.id) + result = self.edit_service.save_appending(overwrite = False) + len2= len(self.series.data_values) + assert len1 == len2 + assert news.data_values[0].data_value == svalue.data_value + 5 assert result From 6451515b2c670d1f6a7e1e83d88f233cc408788d Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 17 May 2016 17:47:06 -0600 Subject: [PATCH 05/18] fix test typo --- tests/test_odmservices/test_edit_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_odmservices/test_edit_service.py b/tests/test_odmservices/test_edit_service.py index 2ba40e1..4e00d40 100644 --- a/tests/test_odmservices/test_edit_service.py +++ b/tests/test_odmservices/test_edit_service.py @@ -105,7 +105,7 @@ def test_save_append_overwrite(self): self.edit_service.memDB.updateValue([svalue.local_date_time],'+', 5 ) news= self.edit_service.memDB.series_service.get_series_by_id(self.series.id) - result = self.edit_service.save_appending(overwrite = False) + result = self.edit_service.save_appending(overwrite = True) len2= len(self.series.data_values) assert len1 == len2 assert news.data_values[0].data_value == svalue.data_value + 5 From 8d56b3f0e227d1123a4f5d915b95c83618337c5d Mon Sep 17 00:00:00 2001 From: stephanie Date: Thu, 19 May 2016 16:18:40 -0600 Subject: [PATCH 06/18] run travis --- .travis.yml | 5 +++++ tests/test_odmservices/test_edit_service.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7ee912..14f2282 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,14 +43,19 @@ addons: # mariadb: '10.1' before_script: + - chmod +x ./tests/scripts/mysql_setup.sh + - chmod +x ./tests/scripts/postgres_setup.sh + - chmod +x ./tests/scripts/freetds.sh - ./tests/scripts/mysql_setup.sh - ./tests/scripts/postgres_setup.sh - ./tests/scripts/freetds.sh + before_install: # python -m pip makes the install go into the virtualenv - python -m pip install pandas - export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1;python -m pip install pymssql + # - python -m pip install mysql-python install: # now just our code - pip install geoalchemy2 diff --git a/tests/test_odmservices/test_edit_service.py b/tests/test_odmservices/test_edit_service.py index 4e00d40..879113d 100644 --- a/tests/test_odmservices/test_edit_service.py +++ b/tests/test_odmservices/test_edit_service.py @@ -103,7 +103,7 @@ def test_save_append_overwrite(self): len1= len(self.series.data_values) svalue = self.series.data_values[0] - self.edit_service.memDB.updateValue([svalue.local_date_time],'+', 5 ) + self.edit_service.memDB.updateValue([svalue.local_date_time],'+', 5) news= self.edit_service.memDB.series_service.get_series_by_id(self.series.id) result = self.edit_service.save_appending(overwrite = True) len2= len(self.series.data_values) From 788a61f1152741c3a43fbe68fa6e0f6b0d38f25d Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 20 May 2016 11:04:03 -0600 Subject: [PATCH 07/18] update testing scripts --- tests/scripts/postgres_setup.sh | 4 ++-- tests/scripts/sampledb/odm_postgres.sql | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/scripts/postgres_setup.sh b/tests/scripts/postgres_setup.sh index 63b052a..6e9df60 100644 --- a/tests/scripts/postgres_setup.sh +++ b/tests/scripts/postgres_setup.sh @@ -2,9 +2,9 @@ psql -U postgres -c "create extension postgis" psql -c 'DROP DATABASE IF EXISTS odmtest;' -U postgres; psql -c 'create database odmtest;' -U postgres; -#psql -U postgres -d odmtest -a -f ./tests/scripts/sampledb/odm_postgresql.sql +#psql -U postgres -d odmtest -a -f .tests/scripts/sampledb/odm_postgres.sql psql -c 'DROP DATABASE IF EXISTS odm;' -U postgres; psql -c 'create database odm;' -U postgres; ## install # add -a to psql to see full log, -q is quiet -psql -U postgres -q -f ./tests/scripts/sampledb/odm_postgresql.sql \ No newline at end of file +psql -U postgres -q -f .tests/scripts/sampledb/odm_postgres.sql \ No newline at end of file diff --git a/tests/scripts/sampledb/odm_postgres.sql b/tests/scripts/sampledb/odm_postgres.sql index 94c12bc..bae8239 100644 --- a/tests/scripts/sampledb/odm_postgres.sql +++ b/tests/scripts/sampledb/odm_postgres.sql @@ -1,3 +1,6 @@ +CREATE DATABASE IF NOT EXISTS `odm` /*!40100 DEFAULT CHARACTER SET latin1 */; +USE `odm`; + CREATE TABLE categories ( VariableID int NOT NULL, DataValue float8 NOT NULL, From a863bbf5e93567a6639fd518ba95501261e84b08 Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 20 May 2016 11:23:31 -0600 Subject: [PATCH 08/18] fix typo in script --- tests/scripts/mysql_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/mysql_setup.sh b/tests/scripts/mysql_setup.sh index f27eb53..a164c6e 100644 --- a/tests/scripts/mysql_setup.sh +++ b/tests/scripts/mysql_setup.sh @@ -21,7 +21,7 @@ mysql -e "create database IF NOT EXISTS odm2test;" --user=root ##### # install ##### -ls -al ./tests/scripts/sampledb/odm_mysql.sql ./tests/scripts/sampledb/odm_postgresql.sql +ls -al ./tests/scripts/sampledb/odm_mysql.sql ./tests/scripts/sampledb/odm_postgres.sql mysql --user=ODM --password=odm odm < ./tests/scripts/sampledb/odm_mysql.sql mysql --user=root -e "show databases;" mysql --user=root -e "GRANT ALL PRIVILEGES ON odm.* TO 'ODM'@'localhost';FLUSH PRIVILEGES;" From 2b4f8d4b884ea24800ce32cce62190d0ed5d0c30 Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 20 May 2016 11:32:59 -0600 Subject: [PATCH 09/18] update mysql scripts --- tests/scripts/mysql_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/mysql_setup.sh b/tests/scripts/mysql_setup.sh index a164c6e..d6c5a43 100644 --- a/tests/scripts/mysql_setup.sh +++ b/tests/scripts/mysql_setup.sh @@ -28,5 +28,5 @@ mysql --user=root -e "GRANT ALL PRIVILEGES ON odm.* TO 'ODM'@'localhost';FLUSH # these should produce results, if they don't the lower_case_table_names failed # should make them grep or sed for some keywords mysql --user=ODM --password=odm odm -e "use odm; Select * from Variables;" -mysql --user=ODM --password=odm odm -e "Select * from Variables;" -mysql --user=ODM --password=odm -e "Select * from Variables;" \ No newline at end of file +mysql --user=ODM --password=odm odm -e "use odm; Select * from Variables;" +mysql --user=ODM --password=odm -e "use odm; Select * from Variables;" \ No newline at end of file From ac5382d6f124add6be16eebd3fe3a1d9a0c0033e Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 20 May 2016 11:46:10 -0600 Subject: [PATCH 10/18] fix postgres script --- tests/scripts/postgres_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/postgres_setup.sh b/tests/scripts/postgres_setup.sh index 6e9df60..7874f5d 100644 --- a/tests/scripts/postgres_setup.sh +++ b/tests/scripts/postgres_setup.sh @@ -2,9 +2,9 @@ psql -U postgres -c "create extension postgis" psql -c 'DROP DATABASE IF EXISTS odmtest;' -U postgres; psql -c 'create database odmtest;' -U postgres; -#psql -U postgres -d odmtest -a -f .tests/scripts/sampledb/odm_postgres.sql +#psql -U postgres -d odmtest -a -f ./tests/scripts/sampledb/odm_postgres.sql psql -c 'DROP DATABASE IF EXISTS odm;' -U postgres; psql -c 'create database odm;' -U postgres; ## install # add -a to psql to see full log, -q is quiet -psql -U postgres -q -f .tests/scripts/sampledb/odm_postgres.sql \ No newline at end of file +psql -U postgres -q -f ./tests/scripts/sampledb/odm_postgres.sql \ No newline at end of file From ff14c63c7cb850145818d5f73a1dbf61cf261495 Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Fri, 20 May 2016 12:24:44 -0600 Subject: [PATCH 11/18] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14f2282..f75f11c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,10 +44,10 @@ addons: # mariadb: '10.1' before_script: - chmod +x ./tests/scripts/mysql_setup.sh - - chmod +x ./tests/scripts/postgres_setup.sh +# - chmod +x ./tests/scripts/postgres_setup.sh - chmod +x ./tests/scripts/freetds.sh - ./tests/scripts/mysql_setup.sh - - ./tests/scripts/postgres_setup.sh +# - ./tests/scripts/postgres_setup.sh - ./tests/scripts/freetds.sh From f1370b928b6f56d8eb7f33077ff6b9b212834e11 Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 20 May 2016 12:32:19 -0600 Subject: [PATCH 12/18] change travis script --- .travis.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index f75f11c..613e76f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,15 +41,6 @@ addons: - wx2.8-headers - wx2.8-i18n -# mariadb: '10.1' -before_script: - - chmod +x ./tests/scripts/mysql_setup.sh -# - chmod +x ./tests/scripts/postgres_setup.sh - - chmod +x ./tests/scripts/freetds.sh - - ./tests/scripts/mysql_setup.sh -# - ./tests/scripts/postgres_setup.sh - - ./tests/scripts/freetds.sh - before_install: # python -m pip makes the install go into the virtualenv @@ -65,8 +56,17 @@ install: # now just our code # don't forget to open up the azure mssql server to these addreses # https://docs.travis-ci.com/user/ip-addresses/ +# mariadb: '10.1' +before_script: + - chmod +x ./tests/scripts/mysql_setup.sh +# - chmod +x ./tests/scripts/postgres_setup.sh + - chmod +x ./tests/scripts/freetds.sh + - ./tests/scripts/mysql_setup.sh +# - ./tests/scripts/postgres_setup.sh + - ./tests/scripts/freetds.sh + # command to run tests script: - - pythonw -m pytest -# - py.test +# - pythonw -m pytest + - py.test From 81f749b2102d5b4ae179d0968fa4560609ecad4d Mon Sep 17 00:00:00 2001 From: stephanie Date: Mon, 23 May 2016 15:13:24 -0600 Subject: [PATCH 13/18] move icon imports --- odmtools/gui/mnuRibbon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odmtools/gui/mnuRibbon.py b/odmtools/gui/mnuRibbon.py index 289a5fc..df63319 100755 --- a/odmtools/gui/mnuRibbon.py +++ b/odmtools/gui/mnuRibbon.py @@ -15,7 +15,7 @@ from odmtools.controller.frmLinearDrift import frmLinearDrift from odmtools.controller.frmAbout import frmAbout import wizSave -from odmtools.common import * +from odmtools.common.icons import * import pandas as pd From 3623f5e7e10e749f39461847f044a30fabfed56e Mon Sep 17 00:00:00 2001 From: sreeder Date: Tue, 24 May 2016 13:12:44 -0600 Subject: [PATCH 14/18] fix issue #272 --- setup/Windows/odmtools_console.iss | 3 ++- setup/Windows/odmtools_no_console.iss | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup/Windows/odmtools_console.iss b/setup/Windows/odmtools_console.iss index bfe3440..b3b464e 100644 --- a/setup/Windows/odmtools_console.iss +++ b/setup/Windows/odmtools_console.iss @@ -2,10 +2,11 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "ODMTools" +#define MyAppInstallName "ODMTools_1.2.3_Beta_win32_x86_64_console.exe" #define MyAppVersion "1.2.3_Beta" #define MyAppPublisher "ODM2" #define MyAppURL "https://github.com/ODM2/ODMToolsPython" -#define MyAppExeName "ODMTools_1.2.3_Beta_win32_x86_64_console.exe" +#define MyAppExeName "ODMTools.exe" #define MyAppDir "D:\DEV\ODMToolsPython" [Setup] diff --git a/setup/Windows/odmtools_no_console.iss b/setup/Windows/odmtools_no_console.iss index 6376d00..b031365 100644 --- a/setup/Windows/odmtools_no_console.iss +++ b/setup/Windows/odmtools_no_console.iss @@ -1,11 +1,13 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + #define MyAppName "ODMTools" +#define MyAppInstallName "ODMTools_1.2.3_Beta_win32_x86_64.exe" #define MyAppVersion "1.2.3_Beta" #define MyAppPublisher "ODM2" #define MyAppURL "https://github.com/ODM2/ODMToolsPython" -#define MyAppExeName "ODMTools_1.2.3_Beta_win32_x86_64.exe" +#define MyAppExeName "ODMTools.exe" #define MyAppDir "D:\DEV\ODMToolsPython" [Setup] From c864c76fb897ebfbfe8f39c21c398f4fd94a7b16 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 7 Jun 2016 16:52:01 -0600 Subject: [PATCH 15/18] update tests add fix for wizSave Method error --- odmtools/controller/pageExisting.py | 4 +- odmtools/gui/pageMethod.py | 13 ++-- odmtools/gui/pageQCL.py | 4 +- odmtools/gui/pageSummary.py | 4 +- odmtools/gui/wizSave.py | 51 ++++++++------ odmtools/odmservices/edit_service.py | 3 +- odmtools/odmservices/series_service.py | 1 + odmtools/odmservices/service_manager.py | 43 ++++++------ odmtools/view/clsCreateVariable.py | 2 +- tests/test_gui/test_wizSave.py | 63 +++++++++++++++++ .../test_odmservices/test_service_manager.py | 68 +++++++++++++++++++ 11 files changed, 200 insertions(+), 56 deletions(-) create mode 100644 tests/test_gui/test_wizSave.py create mode 100644 tests/test_odmservices/test_service_manager.py diff --git a/odmtools/controller/pageExisting.py b/odmtools/controller/pageExisting.py index efbcb6c..0544cfe 100644 --- a/odmtools/controller/pageExisting.py +++ b/odmtools/controller/pageExisting.py @@ -13,7 +13,7 @@ ######################################################################## class pageExisting(wiz.WizardPageSimple): - def __init__(self, parent, title, service_man, site): + def __init__(self, parent, title, series_service , site): """Constructor""" wiz.WizardPageSimple.__init__(self, parent) @@ -30,7 +30,7 @@ def __init__(self, parent, title, service_man, site): #pos=wx.Point(536, 285), size=wx.Size(439, 357), #style=wx.TAB_TRAVERSAL)#, sm = service_man, series = series) self.sizer.Add(self.pnlExisting, 85, wx.ALL, 5) - self._init_data(service_man.get_series_service(), site.id) + self._init_data(series_service, site.id) self.pnlExisting.olvSeriesList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnOLVItemSelected) diff --git a/odmtools/gui/pageMethod.py b/odmtools/gui/pageMethod.py index f422d4a..abff010 100644 --- a/odmtools/gui/pageMethod.py +++ b/odmtools/gui/pageMethod.py @@ -67,8 +67,8 @@ def _init_ctrls(self, prnt): - def __init__(self, parent, id, pos, size, style, name, sm, method): - self.series_service = sm.get_series_service() + def __init__(self, parent, id, pos, size, style, name, ss, method): + self.series_service = ss self.prev_val = method self._init_ctrls(parent) @@ -108,10 +108,10 @@ def getMethod(self): m = Method() if self.rbGenerate.Value: genmethod = "Values derived from ODM Tools Python" - - try: - m= self.series_service.get_method_by_description(genmethod) - except: + m= self.series_service.get_method_by_description(genmethod) + if m is None: + logger.debug("assigning new method description") + m = Method() m.description = genmethod elif self.rbSelect.Value: @@ -124,5 +124,6 @@ def getMethod(self): elif self.rbCreateNew.Value: + logger.debug("assigning new method description") m.description = self.txtMethodDescrip.GetValue() return m \ No newline at end of file diff --git a/odmtools/gui/pageQCL.py b/odmtools/gui/pageQCL.py index af0e411..359c611 100644 --- a/odmtools/gui/pageQCL.py +++ b/odmtools/gui/pageQCL.py @@ -84,8 +84,8 @@ def _init_ctrls(self, prnt): label=u'Explanation:', name=u'lblExplanation', parent=self, pos=wx.Point(16, 248), size=wx.Size(61, 13), style=0) - def __init__(self, parent, id, pos, size, style, name, sm, qcl): - self.series_service = sm.get_series_service() + def __init__(self, parent, id, pos, size, style, name, ss, qcl): + self.series_service = ss self.prev_val = qcl self._init_ctrls(parent) diff --git a/odmtools/gui/pageSummary.py b/odmtools/gui/pageSummary.py index 5822eb1..a9a9be2 100644 --- a/odmtools/gui/pageSummary.py +++ b/odmtools/gui/pageSummary.py @@ -35,8 +35,8 @@ def _init_ctrls(self, prnt): self._init_sizers() - def __init__(self, parent, id, size, style, name, sm, pos= (0,0)): - self.series_service = sm.get_series_service() + def __init__(self, parent, id, size, style, name, ss, pos= (0,0)): + self.series_service = ss self._init_ctrls(parent) diff --git a/odmtools/gui/wizSave.py b/odmtools/gui/wizSave.py index 5986cc1..ffd96ad 100644 --- a/odmtools/gui/wizSave.py +++ b/odmtools/gui/wizSave.py @@ -24,7 +24,7 @@ ######################################################################## class QCLPage(wiz.WizardPageSimple): - def __init__(self, parent, title, service_man, qcl): + def __init__(self, parent, title, series_service, qcl): """Constructor""" wiz.WizardPageSimple.__init__(self, parent) @@ -39,10 +39,10 @@ def __init__(self, parent, title, service_man, qcl): sizer.Add(wx.StaticLine(self, -1), 5, wx.EXPAND | wx.ALL, 5) self.panel = pageQCL.pnlQCL(self, id=wxID_PNLQCL, name=u'pnlQCL', pos=wx.Point(536, 285), size=wx.Size(439, 357), - style=wx.TAB_TRAVERSAL, sm=service_man, qcl=qcl) + style=wx.TAB_TRAVERSAL, ss=series_service, qcl=qcl) self.sizer.Add(self.panel, 85, wx.ALL, 5) - series_service = service_man.get_series_service() - self._init_data(series_service) + + self._init_data(self.panel.series_service) def _init_data(self, series): qcl = series.get_all_qcls() @@ -61,7 +61,7 @@ def _init_data(self, series): ######################################################################## class VariablePage(wiz.WizardPageSimple): - def __init__(self, parent, title, service_man, var): + def __init__(self, parent, title, service_manager, var): """Constructor""" wiz.WizardPageSimple.__init__(self, parent) @@ -76,10 +76,10 @@ def __init__(self, parent, title, service_man, var): sizer.Add(wx.StaticLine(self, -1), 5, wx.EXPAND | wx.ALL, 5) self.panel = pageVariable.pnlVariable(self, id=wxID_PNLVARIABLE, name=u'pnlVariable', pos=wx.Point(536, 285), size=wx.Size(439, 357), - style=wx.TAB_TRAVERSAL, sm=service_man, var=var) + style=wx.TAB_TRAVERSAL, sm=service_manager, var=var) self.sizer.Add(self.panel, 85, wx.ALL, 5) - series_service = service_man.get_series_service() - self._init_data(series_service) + + self._init_data(self.panel.series_service) def _init_data(self, series_service): vars = series_service.get_all_variables() @@ -108,7 +108,7 @@ def _init_data(self, series_service): ######################################################################## class MethodPage(wiz.WizardPageSimple): - def __init__(self, parent, title, service_man, method): + def __init__(self, parent, title, series_service, method): """Constructor""" wiz.WizardPageSimple.__init__(self, parent) @@ -123,10 +123,10 @@ def __init__(self, parent, title, service_man, method): sizer.Add(wx.StaticLine(self, -1), 5, wx.EXPAND | wx.ALL, 5) self.panel = pageMethod.pnlMethod(self, id=wxID_PNLMETHOD, name=u'pnlMethod', pos=wx.Point(536, 285), size=wx.Size(439, 357), - style=wx.TAB_TRAVERSAL, sm=service_man, method=method) + style=wx.TAB_TRAVERSAL, ss=series_service, method=method) self.sizer.Add(self.panel, 85, wx.ALL, 5) - series_service = service_man.get_series_service() - self._init_data(series_service) + + self._init_data(self.panel.series_service) def _init_data(self, series): meth = series.get_all_methods() @@ -146,7 +146,7 @@ def _init_data(self, series): ######################################################################## class SummaryPage(wiz.WizardPageSimple): - def __init__(self, parent, title, service_man): + def __init__(self, parent, title, series_service): """Constructor""" wiz.WizardPageSimple.__init__(self, parent) self.parent = parent @@ -160,7 +160,7 @@ def __init__(self, parent, title, service_man): sizer.Add(wx.StaticLine(self, -1), 5, wx.EXPAND | wx.ALL, 5) self.panel = pageSummary.pnlSummary(self, id=wxID_PNLSUMMARY, name=u'pnlSummary', pos=wx.Point(536, 285), size=wx.Size(439, 357), - style=wx.TAB_TRAVERSAL, sm=service_man) + style=wx.TAB_TRAVERSAL, ss=series_service) self.sizer.Add(self.panel, 85, wx.ALL, 5) @@ -215,34 +215,41 @@ def _init_ctrls(self, prnt): def get_metadata(self): if self.pgIntro.pnlIntroduction.rbSaveAs.GetValue(): + logger.debug("SaveAs") method = self.pgMethod.panel.getMethod() qcl = self.pgQCL.panel.getQCL() variable = self.pgVariable.panel.getVariable() elif self.pgIntro.pnlIntroduction.rbSave.GetValue(): + logger.debug("Save") method = self.currSeries.method qcl = self.currSeries.quality_control_level variable = self.currSeries.variable elif self.pgIntro.pnlIntroduction.rbSaveExisting.GetValue(): + logger.debug("Existing") method, qcl, variable = self.pgExisting.getSeries() site = self.currSeries.site source = self.currSeries.source logger.debug("site: %s, variable: %s, method: %s, source: %s, qcl: %s" % ( - site.id, variable.id, method.id, source.id, qcl.id)) + str(site), str(variable), str(method), str(source), str(qcl))) return site, variable, method, source, qcl - def __init__(self, parent, service_man, record_service): + def __init__(self, parent, service_manager, record_service): self._init_ctrls(parent) - self.series_service = service_man.get_series_service() + try: + self.series_service = record_service._edit_service.memDB.series_service #service_man.get_series_service() + except: + #for testing + self.series_service = record_service.memDB.series_service self.record_service = record_service # self.is_changing_series = False self.currSeries = record_service.get_series() self.pgIntro = pageIntro.pageIntro(self, "Intro") - self.pgMethod = MethodPage(self, "Method", service_man, self.currSeries.method) - self.pgQCL = QCLPage(self, "Quality Control Level", service_man, self.currSeries.quality_control_level) - self.pgVariable = VariablePage(self, "Variable", service_man, self.currSeries.variable) - self.pgExisting = pageExisting.pageExisting(self, "Existing Series", service_man, self.currSeries.site) - self.pgSummary = SummaryPage(self, "Summary", service_man) + self.pgMethod = MethodPage(self, "Method", self.series_service, self.currSeries.method) + self.pgQCL = QCLPage(self, "Quality Control Level", self.series_service, self.currSeries.quality_control_level) + self.pgVariable = VariablePage(self, "Variable", service_manager, self.currSeries.variable) + self.pgExisting = pageExisting.pageExisting(self, "Existing Series", self.series_service, self.currSeries.site) + self.pgSummary = SummaryPage(self, "Summary", self.series_service) self.FitToPage(self.pgIntro) diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index f6a87ee3..63bee34 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -35,11 +35,10 @@ def __init__(self, series_id, connection=None, connection_string="", debug=False if connection_string is "" and connection is not None: self.memDB= connection - #self._series_service = self.memDB.series_service#SeriesService(connection_string, debug) elif connection_string is not "" and connection is None: from odmtools.odmdata import MemoryDatabase - self.memDB= MemoryDatabase()#(series_service) + self.memDB= MemoryDatabase() self.memDB.set_series_service(SeriesService(connection_string, False)) diff --git a/odmtools/odmservices/series_service.py b/odmtools/odmservices/series_service.py index c843fa7..d3db139 100644 --- a/odmtools/odmservices/series_service.py +++ b/odmtools/odmservices/series_service.py @@ -233,6 +233,7 @@ def get_method_by_description(self, method_code): result = self._edit_session.query(Method).filter_by(description=method_code).first() except: result = None + logger.error("method not found") return result def get_offset_types_by_series_id(self, series_id): diff --git a/odmtools/odmservices/service_manager.py b/odmtools/odmservices/service_manager.py index 2ba80b8..19d7449 100755 --- a/odmtools/odmservices/service_manager.py +++ b/odmtools/odmservices/service_manager.py @@ -21,7 +21,7 @@ class ServiceManager(): - def __init__(self, debug=False): + def __init__(self, debug=False, conn_dict = None): self.debug = debug f = self._get_file('r') self._conn_dicts = [] @@ -29,23 +29,26 @@ def __init__(self, debug=False): self._connection_format = "%s+%s://%s:%s@%s/%s" # Read all lines (connections) in the connection.cfg file - while True: - line = f.readline() - if not line: - break - else: - line = line.split() - #logger.debug(line) - - if len(line) >= 5: - line_dict = {} - - line_dict['engine'] = line[0] - line_dict['user'] = line[1] - line_dict['password'] = line[2] - line_dict['address'] = line[3] - line_dict['db'] = line[4] - self._conn_dicts.append(line_dict) + if conn_dict is None: + while True: + line = f.readline() + if not line: + break + else: + line = line.split() + #logger.debug(line) + + if len(line) >= 5: + line_dict = {} + + line_dict['engine'] = line[0] + line_dict['user'] = line[1] + line_dict['password'] = line[2] + line_dict['address'] = line[3] + line_dict['db'] = line[4] + self._conn_dicts.append(line_dict) + else: + self._conn_dicts.append(conn_dict) if len(self._conn_dicts) is not 0: # The current connection defaults to the most recent (i.e. the last written to the file) @@ -192,7 +195,9 @@ def _build_connection_string(self, conn_dict): driver = "pyodbc" quoted = urllib.quote_plus('DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password'])) conn_string = 'mssql+pyodbc:///?odbc_connect={}'.format(quoted) - + elif conn_dict['engine']=='sqlite': + connformat = "%s:///%s" + conn_string = connformat%(conn_dict['engine'], conn_dict['address']) else: if conn_dict['engine'] == 'mssql': driver = "pyodbc" diff --git a/odmtools/view/clsCreateVariable.py b/odmtools/view/clsCreateVariable.py index 50de13e..17615eb 100644 --- a/odmtools/view/clsCreateVariable.py +++ b/odmtools/view/clsCreateVariable.py @@ -127,7 +127,7 @@ def __init__(self, parent): #fgSizer6.Add(self.txtGenCat, 0, wx.ALL | wx.EXPAND, 5) cbGenCatChoices = [] - self.cbGenCat = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbGenCatChoices, wx.CB_READONLY|wx.CB_SORT ) + self.cbGenCat = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbGenCatChoices, wx.CB_READONLY)#|wx.CB_SORT )#sort not supported by mac fgSizer6.Add( self.cbGenCat, 0, wx.ALL|wx.EXPAND, 5 ) self.stNoDV = wx.StaticText(self, wx.ID_ANY, u"NoDataValue:", wx.DefaultPosition, wx.DefaultSize, 0) diff --git a/tests/test_gui/test_wizSave.py b/tests/test_gui/test_wizSave.py new file mode 100644 index 0000000..038faee --- /dev/null +++ b/tests/test_gui/test_wizSave.py @@ -0,0 +1,63 @@ +from unittest import TestCase + +__author__ = 'stephanie' + +from odmtools.gui.wizSave import wizSave +from odmtools.odmdata import MemoryDatabase +from odmtools.odmservices import ServiceManager +from odmtools.odmservices import SeriesService + +from tests import test_util +import wx + + + + +class TestWizSave: + def setup(self): + conn_dict = {'engine': 'sqlite', 'address': ':memory:'} + self.sm = ServiceManager(conn_dict=conn_dict) + # set up remote Database + # self.connection_string = "sqlite:///:memory:" + + self.series_service = self.sm.get_series_service() # SeriesService(connection_string=self.connection_string, debug=False) + self.session = self.series_service._session_factory.get_session() + engine = self.series_service._session_factory.engine + test_util.build_db(engine) + + self.dvs_size = 100 + self.series = test_util.add_series_bulk_data(self.session, dvs_size=self.dvs_size) + assert self.series + assert len(self.series.data_values) == self.dvs_size + + self.memory_database = MemoryDatabase() + self.memory_database.set_series_service(self.series_service) + # self.memory_database.initEditValues(self.series.id) + + self.app = wx.App() + self.frame = wx.Frame(None) + self.wizard = wizSave(self.frame,self.sm, self.sm.get_edit_service(self.series.id, self.memory_database)) +#TODO get wizard tests working + # def test___init__(self): + # assert self.frame + # assert self.wizard + # self.wizard.init(self, self.sm, self.memory_database) + # + # + # def test__init_ctrls(self): + # self.fail() + # + # def test_get_metadata(self): + # self.fail() + # + # def test_on_page_changed(self): + # self.fail() + # + # def test_on_page_changing(self): + # self.fail() + # + # def test_on_wizard_finishedtest(self): + # self.fail() + # + # def test_on_wizard_finished(self): + # self.fail() diff --git a/tests/test_odmservices/test_service_manager.py b/tests/test_odmservices/test_service_manager.py new file mode 100644 index 0000000..ed7c0b3 --- /dev/null +++ b/tests/test_odmservices/test_service_manager.py @@ -0,0 +1,68 @@ +__author__ = 'stephanie' + +#TODO implement service_manager tests + + + + +class TestServiceManager(): + def setup(self): + pass + + def test__init(self, debug=False): + pass + + def test_get_all_conn_dicts(self): + pass + + def test_is_valid_connection(self): + pass + + def test_get_current_conn_dict(self): + pass + + def test_set_current_conn_dict(self): + pass + + def test_add_connection(self): + pass + + def test_testEngine(self): + pass + + def test_test_connection(self): + pass + + def test_delete_connection(self): + pass + + def test_get_db_version_dict(self): + pass + + def test_get_db_version(self): + pass + + def test_get_series_service(self): + pass + + def test_get_cv_service(self): + pass + + def test_get_edit_service(self): + pass + + def test_get_record_service(self): + pass + + def test_get_export_service(self): + pass + + def test_get_file(self): + pass + + def test_build_connection_string(self): + pass + + def test_save_connections(self): + pass + From bcb502c7115198ae44227942c04102b51813e4c4 Mon Sep 17 00:00:00 2001 From: sreeder Date: Wed, 8 Jun 2016 11:12:52 -0600 Subject: [PATCH 16/18] funkiness with git --- odmtools/controller/frmSeriesSelector.py | 19 +++++++++-- odmtools/gui/frmODMTools.py | 1 + odmtools/gui/mnuPlotToolbar.py | 42 +++--------------------- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/odmtools/controller/frmSeriesSelector.py b/odmtools/controller/frmSeriesSelector.py index 02f3642..cff28ca 100755 --- a/odmtools/controller/frmSeriesSelector.py +++ b/odmtools/controller/frmSeriesSelector.py @@ -84,6 +84,9 @@ def refreshTableSeries(self, db): :return: """ + chcklist= self.tblSeries.GetCheckedObjects() + + self.memDB.set_series_service(db) object = self.series_service.get_all_series() #checkedObjs = self.tblSeries.GetCheckedObjects() @@ -93,6 +96,11 @@ def refreshTableSeries(self, db): if x.id not in idList: self.tblSeries.AddObject(x) + + for c in chcklist: + self.tblSeries.SetCheckState(c, True) + + #for x in checkedObjs: # super(FastObjectListView, self.tblSeries).SetCheckState(x, True) @@ -555,14 +563,21 @@ def onReadyToEdit(self): def stopEdit(self): """When edit button is untoggled, the editing feature closes - :return: """ + self.isEditing = False + if self.tblSeries.editingObject in self.tblSeries.GetCheckedObjects(): + ischecked =True + else: + ischecked = False self.tblSeries.RefreshObject(self.tblSeries.editingObject) - self.tblSeries.editingObject = None + if ischecked and self.tblSeries.editingObject not in self.tblSeries.GetCheckedObjects(): + self.tblSeries.ToggleCheck(self.tblSeries.editingObject) + self.memDB.stopEdit() + def isEditing(self): """ diff --git a/odmtools/gui/frmODMTools.py b/odmtools/gui/frmODMTools.py index b96a7c8..798350c 100755 --- a/odmtools/gui/frmODMTools.py +++ b/odmtools/gui/frmODMTools.py @@ -442,6 +442,7 @@ def stopEdit(self, event): self.dataTable.stopEdit() self.pnlPlot.stopEdit() Publisher.sendMessage("toggleEdit", checked=False) + self.memDB.reset_edit() self.record_service = None self._ribbon.toggleEditButtons(False) diff --git a/odmtools/gui/mnuPlotToolbar.py b/odmtools/gui/mnuPlotToolbar.py index 527d425..985d603 100644 --- a/odmtools/gui/mnuPlotToolbar.py +++ b/odmtools/gui/mnuPlotToolbar.py @@ -132,7 +132,7 @@ def __init__(self, plotCanvas, multPlots=False, allowselect=False): self.msg = wx.StaticText(self, -1, "") self.AddControl(self.msg) - self.canvas.mpl_connect('scroll_event', self.on_scroll_zoom) + self.Realize() def editSeries(self, xys, edit): @@ -149,6 +149,8 @@ def stopEdit(self): self.xys = None self.editCurve = None self.lassoAction = None + # untoggle select button + self.ToggleTool(self.select_tool.Id, False) # disable select button self.select_tool.Enable(False) self.zoom_to_data.Enable(False) @@ -157,7 +159,7 @@ def stopEdit(self): #self.ToggleTool(self.select_tool.Id, False) - # pan the graph to the left + # pan the graph to the left def _on_custom_pan_left(self, evt): ONE_SCREEN = 7 # we default to 1 week axes = self.canvas.figure.axes[0] @@ -248,8 +250,6 @@ def on_toggle_zoom_data_tool(self, event): self.canvas.draw() - - #must add these methods for mac functionality def release_zoom(self, event): super(self.__class__, self).release_zoom(event) @@ -266,37 +266,3 @@ def forward(self, event): def home(self, event): super(self.__class__, self).home(event) self.canvas.draw() - - - - - def on_scroll_zoom(self, event): - axes = self.canvas.figure.axes[0] - base_scale = 1.2 - # get the current x and y limits - cur_xlim = axes.get_xlim() - cur_ylim = axes.get_ylim() - cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5 - cur_yrange = (cur_ylim[1] - cur_ylim[0])*.5 - xdata = event.xdata # get event x location - ydata = event.ydata # get event y location - if event.button == 'up': - # deal with zoom in - scale_factor = 1/base_scale - elif event.button == 'down': - # deal with zoom out - scale_factor = base_scale - else: - # deal with something that should never happen - scale_factor = 1 - print event.button - # set new limits - axes.set_xlim([xdata - cur_xrange*scale_factor, - xdata + cur_xrange*scale_factor]) - axes.set_ylim([ydata - cur_yrange*scale_factor, - ydata + cur_yrange*scale_factor]) - self.canvas.draw() # force re-draw - - # fig = ax.get_figure() # get the figure of interest - # attach the call back - From 611900dd2f95af23fdc94f6d92b03fe73e0b54bf Mon Sep 17 00:00:00 2001 From: sreeder Date: Wed, 8 Jun 2016 11:42:26 -0600 Subject: [PATCH 17/18] fix issue #274, fixed reoccurance of issue #264 --- odmtools/controller/frmSeriesSelector.py | 19 +++++++++++++------ odmtools/odmdata/series.py | 17 +++++++++++++++++ odmtools/odmservices/edit_service.py | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/odmtools/controller/frmSeriesSelector.py b/odmtools/controller/frmSeriesSelector.py index cff28ca..7852965 100755 --- a/odmtools/controller/frmSeriesSelector.py +++ b/odmtools/controller/frmSeriesSelector.py @@ -109,12 +109,21 @@ def refreshSeries(self): :return: """ + chcklist= self.tblSeries.GetCheckedObjects() self.series_service = None + self.series_service = self.parent.Parent.createService() #self.refreshTableSeries(self.dbservice) self.resetDB(self.series_service) + for c in chcklist: + for val in self.tblSeries.GetObjects(): + if c == val: + self.tblSeries.SetCheckState(val, True) + break + logger.debug("Repopulate Series Selector") + def initSVBoxes(self): """ @@ -567,13 +576,11 @@ def stopEdit(self): """ self.isEditing = False - if self.tblSeries.editingObject in self.tblSeries.GetCheckedObjects(): - ischecked =True - else: - ischecked = False + chcklist= self.tblSeries.GetCheckedObjects() + self.tblSeries.RefreshObject(self.tblSeries.editingObject) - if ischecked and self.tblSeries.editingObject not in self.tblSeries.GetCheckedObjects(): - self.tblSeries.ToggleCheck(self.tblSeries.editingObject) + for c in chcklist: + self.tblSeries.SetCheckState(c, True) self.memDB.stopEdit() diff --git a/odmtools/odmdata/series.py b/odmtools/odmdata/series.py index 3510dbf..cae849c 100644 --- a/odmtools/odmdata/series.py +++ b/odmtools/odmdata/series.py @@ -96,6 +96,23 @@ class Series(Base): def __repr__(self): return "" % (self.id, self.site_name, self.variable_code, self.variable_name) + def __eq__(self, other) : + # return self.__dict__ == other.__dict__ + return [self.id, self.site_id, self.site_code, self.site_name, self.variable_id, self.variable_code, + self.variable_name, self.speciation, self.variable_units_id, self.variable_units_name, + self.sample_medium, self.value_type, self.time_support, self.time_units_id, self.time_units_name, + self.data_type, self.general_category, self.method_id, self.method_description, + self.source_id, self.source_description, self.organization, self.citation, + self.quality_control_level_id, self.quality_control_level_code, self.begin_date_time, + self.end_date_time, self.begin_date_time_utc, self.end_date_time_utc, self.value_count] ==\ + [other.id, other.site_id, other.site_code, other.site_name, other.variable_id, other.variable_code, + other.variable_name, other.speciation, other.variable_units_id, other.variable_units_name, + other.sample_medium, other.value_type, other.time_support, other.time_units_id, other.time_units_name, + other.data_type, other.general_category, other.method_id, other.method_description, + other.source_id, other.source_description, other.organization, other.citation, + other.quality_control_level_id, other.quality_control_level_code, other.begin_date_time, + other.end_date_time, other.begin_date_time_utc, other.end_date_time_utc, other.value_count] + def get_table_columns(self): return self.__table__.columns.keys() diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index 63bee34..cb65fce 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -504,7 +504,7 @@ def updateSeries(self, var=None, method=None, qcl=None, is_new_series=False, ove #if series end date is after dvs startdate dbend = series.end_date_time dfstart = datetime.datetime.strptime(str(np.min(dvs["LocalDateTime"])), form) - overlap = dbend> dfstart + overlap = dbend>= dfstart #leave series start dates to those previously set series.end_date_time = datetime.datetime.strptime(str(np.max(dvs["LocalDateTime"])), form) series.end_date_time_utc = datetime.datetime.strptime(str(np.max(dvs["DateTimeUTC"])), form) From a3f93c07d0ff15f6c9d02dc924698dbb71515306 Mon Sep 17 00:00:00 2001 From: stephanie Date: Fri, 10 Jun 2016 14:09:29 -0600 Subject: [PATCH 18/18] debug statement for histogram issue --- odmtools/gui/plotHistogram.py | 1 + odmtools/gui/pnlPlot.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/odmtools/gui/plotHistogram.py b/odmtools/gui/plotHistogram.py index 219781b..c6698ed 100644 --- a/odmtools/gui/plotHistogram.py +++ b/odmtools/gui/plotHistogram.py @@ -99,6 +99,7 @@ def _createPlot(self, oneSeries, rows, cols, index): ax = self.figure.add_subplot(repr(rows) + repr(cols) + repr(index)) logger.debug("HISTOGRAM: %s"% ax) + logger.debut("rows: %s cols: %s, index: %s"%(rows, cols, index)) # oneSeries.filteredData.hist(ax= ax, color='k', alpha=0.5, bins=50) diff --git a/odmtools/gui/pnlPlot.py b/odmtools/gui/pnlPlot.py index 230c8b6..9788b7c 100644 --- a/odmtools/gui/pnlPlot.py +++ b/odmtools/gui/pnlPlot.py @@ -164,11 +164,12 @@ def redrawPlots(self): logger.debug("Plot Boxwhisker") self.pltBox.Plot(self._seriesPlotInfo) + logger.debug("Plot Timeseries") + self.pltTS.Plot(self._seriesPlotInfo) + logger.debug("Plot Histogram") self.pltHist.Plot(self._seriesPlotInfo) - logger.debug("Plot Timeseries") - self.pltTS.Plot(self._seriesPlotInfo) self.onShowLegend(event=None, isVisible=self.legendVisible) maxStart, maxEnd, currStart, currEnd = self._seriesPlotInfo.getDates()