Skip to content

Commit 9dbfd51

Browse files
author
sreeder
committed
should fix issue with add points. issue #243
1 parent e4817f7 commit 9dbfd51

File tree

12 files changed

+32
-31
lines changed

12 files changed

+32
-31
lines changed

ODMTools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
from multiprocessing import cpu_count, freeze_support
1919
from odmtools.odmdata import MemoryDatabase
2020

21-
import pyodbc
22-
import pymysql
23-
import psycopg2
21+
# import pyodbc
22+
# import pymysql
23+
# import psycopg2
2424

2525
tool = LoggerTool()
2626
logger = tool.setupLogger(__name__, __name__ + '.log', 'w', logging.DEBUG)

doc/developer_docs/source/build/executable.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Installing using pyinstaller
4848

4949
easy_install pywin32-219.win-amd64-py2.7.exe
5050

51+
Install Microsoft C++ Redistributable either 2008 or 2010 x86/x64 from https://www.microsoft.com/en-us/download/details.aspx?id=29
52+
Install it to your system
53+
5154
See the `Example <https://mborgerson.com/creating-an-executable-from-a-python-script/>`_ to see how a simple wxpython application can be built with pyinstaller
5255

5356
.. Note::
@@ -56,6 +59,9 @@ Installing using pyinstaller
5659
.. Warning::
5760
Prepare to do a lot of googling as there are a lot of features that aren't clear
5861

62+
.. Warning::
63+
Make sure that you close command prompt and reopen it if you installed any of these packages/software
64+
5965
Here is an example of building a program. There isn't a messy setup.py needed unlike py2exe. These are automatically generated when a user runs the command
6066

6167
::

odmtools/controller/logicEditTools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def saveFactory(self, var=None, method=None, qcl=None):
221221
#values['override'] = override
222222
return values['var'], values['method'], values['qcl']#, values['isSave']
223223

224-
# TODO Create save_as & save_existing
224+
225225
def save(self, var=None, method=None, qcl=None):
226226
"""
227227

odmtools/gui/pnlScript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def OnSaveAs(self, e):
161161
dlg.Destroy()
162162
return False
163163
def runCommand(self, text):
164-
#TODO Stop recording
164+
165165
# get ahold of record service and turn it off do i need a publisher command?
166166

167167
self.parent.record_service.toggle_record(False)

odmtools/odmdata/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,4 @@
6565
'copy_data_value'
6666
]
6767

68-
# pyinstaller needs pymysql, psycopg2, and pyodbc (If on windows)
69-
import sys
70-
if sys.platform is not 'darwin':
71-
import pymysql
72-
import psycopg2
73-
import pyodbc
74-
68+

odmtools/odmdata/memory_database.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ def rollback(self):
9191
#self.updateDF()
9292

9393
def update(self, updates):
94+
'''
95+
updates : list of dictionary that contains 2 items, id and value
96+
'''
9497

9598
stmt = (DataValue.__table__.update().
96-
where(DataValue.id == bindparam('id')).
99+
where(DataValue.local_date_time == bindparam('id')).
97100
values(DataValue=bindparam('value'))
98101
)
99102

@@ -117,19 +120,19 @@ def updateValue(self, ids, operator, value):
117120
#break into chunks to get around sqlites restriction. allowing user to send in only 999 arguments at once
118121
chunks=self.chunking(ids)
119122
for c in chunks:
120-
q=self.mem_service._edit_session.query(DataValue).filter(DataValue.id.in_(c))
123+
q=self.mem_service._edit_session.query(DataValue).filter(DataValue.local_date_time.in_(c))
121124
q.update({DataValue.data_value: query}, False)
122125

123126
#self.updateDF()
124127

125128
def chunking(self, data):
126129
return [data[x:x+998] for x in xrange(0, len(data), 998)]
127130

128-
#break into chunks to get around sqlites restriction. allowing user to send in only 999 arguments at once
131+
#break into chunks to get around sqlite's restriction. allowing user to send in only 999 arguments at once
129132
def updateFlag(self, ids, value):
130133
chunks=self.chunking(ids)
131134
for c in chunks:
132-
self.mem_service._edit_session.query(DataValue).filter(DataValue.id.in_(c))\
135+
self.mem_service._edit_session.query(DataValue).filter(DataValue.local_date_time.in_(c))\
133136
.update({DataValue.qualifier_id: value}, False)
134137

135138

odmtools/odmdata/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Series(Base):
9292
source = relationship(Source)
9393
quality_control_level = relationship(QualityControlLevel)
9494

95-
# TODO add all to repr
95+
9696
def __repr__(self):
9797
return "<Series('%s', '%s', '%s', '%s')>" % (self.id, self.site_name, self.variable_code, self.variable_name)
9898

odmtools/odmservices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# need to explicitly import these for pyinstaller
88
import pymysql
99
import pyodbc
10-
import psycopg2
10+
#import psycopg2
1111

1212
__all__ = [
1313
'EditService',

odmtools/odmservices/edit_service.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ def get_variable(self, variable_id):
294294
def change_value(self, value, operator):
295295
filtered_points = self.get_filtered_points()
296296

297-
ids = filtered_points["ValueID"].astype(int).tolist()
297+
ids = filtered_points.index.tolist()
298298
self.memDB.updateValue(ids, operator, float(value))
299299
self._populate_series()
300300

301301
## update filtered_dataframe
302-
self.filtered_dataframe = self._series_points_df[self._series_points_df['ValueID'].isin(ids)]
302+
self.filtered_dataframe = self._series_points_df[self._series_points_df.index.isin(ids)]
303303

304304
def add_points(self, points):
305305
# todo: add the ability to send in multiple datetimes to a single 'point'
@@ -312,7 +312,7 @@ def add_points(self, points):
312312
def delete_points(self):
313313
filtered_points = self.get_filtered_points()
314314
if not filtered_points.empty:
315-
values = filtered_points['ValueID'].astype(float).tolist()
315+
values = filtered_points.index.tolist()
316316

317317
self.memDB.delete(values)
318318
self._populate_series()
@@ -333,17 +333,17 @@ def interpolate(self):
333333
mdf = df["DataValue"].mask(issel)
334334
mdf.interpolate(method = "time", inplace=True)
335335
tmp_filter_list["DataValue"]=mdf[issel]
336-
ids = tmp_filter_list['ValueID'].tolist()
336+
ids = tmp_filter_list.index.tolist()
337337

338338
#update_list = [(row["DataValue"], row["ValueID"]) for index, row in tmp_filter_list.iterrows()]
339-
update_list = [{"value": row["DataValue"], "id": row["ValueID"]} for index, row in tmp_filter_list.iterrows()]
339+
update_list = [{"value": row["DataValue"], "id": index} for index, row in tmp_filter_list.iterrows()]
340340

341341
self.memDB.update(update_list)
342342

343343

344344
self._populate_series()
345345

346-
self.filtered_dataframe = self._series_points_df[self._series_points_df['ValueID'].isin(ids)]
346+
self.filtered_dataframe = self._series_points_df[self._series_points_df.index.isin(ids)]
347347

348348
def drift_correction(self, gap_width):
349349
if self.isOneGroup():
@@ -355,15 +355,15 @@ def drift_correction(self, gap_width):
355355
f = lambda row : row["DataValue"]+(gap_width * ((row.name-startdate).total_seconds() / x_l))
356356
tmp_filter_list["DataValue"]=tmp_filter_list.apply(f, axis = 1)
357357

358-
update_list = [{"value": row["DataValue"], "id": row["ValueID"]} for index, row in tmp_filter_list.iterrows()]
358+
update_list = [{"value": row["DataValue"], "id":index} for index, row in tmp_filter_list.iterrows()]
359359

360-
ids = tmp_filter_list['ValueID'].tolist()
360+
ids = tmp_filter_list.index.tolist()
361361
self.memDB.update(update_list)
362362

363363

364364
self._populate_series()
365365

366-
self.filtered_dataframe = self._series_points_df[self._series_points_df['ValueID'].isin(ids)]
366+
self.filtered_dataframe = self._series_points_df[self._series_points_df.index.isin(ids)]
367367
return True
368368
return False
369369

@@ -396,7 +396,7 @@ def flag(self, qualifier_id):
396396
#self._cursor.executemany(query, [(str(x[0]),) for x in filtered_points])
397397
self._cursor.executemany(query, [(str(x),) for x in filtered_points["ValueID"].astype(int).tolist()])
398398
'''
399-
self.memDB.updateFlag(filtered_points["ValueID"].astype(int).tolist(), qualifier_id)
399+
self.memDB.updateFlag(filtered_points.index.astype(int).tolist(), qualifier_id)
400400

401401
###################
402402
# Save/Restore

odmtools/view/clsAddPoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def onEdit(self, event):
134134
#print "Editing Cell!", event.subItemIndex
135135

136136
## Ignore editing on first cell
137-
## TODO this is needed for the windows version
137+
## this is needed for the windows version
138138
#if event.subItemIndex == 0:
139139
# event.Veto()
140140
#pass

0 commit comments

Comments
 (0)