class myStore:
# The store saves to self.fn, and drops a copy in self.fn+version. This is the version
# control. So always load from the current version using the default filename. It also
# contains the current version number so no need for filename antics. All results are
# kept in the local `res` directory so store functions ultimately load and save the `res`
# dict.
# Use as,
# res = myStore() # instantiate, get latest version
# r = res.res # shorthand. Refer to r[] as result dict.
# r['testValue'] = 1 # set dict value/
# res.update() # Writes to disk and updates version.
# del(r); del(res)
# res = myStore() # instantiate, get latest version and data.
# r = res.res
# r['testValue'] # works.
import os, pickle, cPickle
def restore(self):
"""Opens the store file, pulls everything from it. Run this at instanciation only."""
with file(self.root + self.filename, 'r') as a:
self.res = self.cPickle.load(a)
self.version = self.cPickle.load(a)
print 'Loaded data from store v%i' % (self.version)
def __init__(self, filename = ''):
self.root = '/home/starnesm/projects/FT/ipython/'
# if a filename given, use it to name the store. Otherwise, use default.
if filename == '':
self.filename = 'carAndBikeImpedanceMeasurementsData.pickle'
else:
self.filename = filename
self.res = dict() # default values
self.version = 1 # to be replaced if store exists:
if (self.filename) in self.os.listdir(self.root):
# the store exists. Load it and get version number.
with file(self.root + self.filename, 'r') as a:
self.res = self.pickle.load(a)
self.version = self.pickle.load(a)
print 'myStore is at version ', self.version
def update(self):
"""Opens the store file, pickles the thing and puts it in it."""
self.version += 1
with file(self.root + self.filename, 'w') as a:
self.pickle.dump(self.res, a)
self.pickle.dump(self.version, a)
with file(self.root + self.filename + '.' + str(self.version), 'w') as a:
self.pickle.dump(self.res, a)
self.pickle.dump(self.version, a)
print 'Version updated to v', self.version
Thursday, 4 June 2015
Wednesday, 27 May 2015
Friday, 22 May 2015
More solar stuff.
PV:
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&client=ubuntu#q=grid+tie+inverter
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&client=ubuntu#q=grid+tie+inverter
Trek district bike parts
https://www.universalcycles.com/shopping/index.php?category=4081
These people look to sell the belt and sprockets for reasonable prices!
These people look to sell the belt and sprockets for reasonable prices!
Tuesday, 19 May 2015
Sunday, 17 May 2015
solar pump
http://www.ebay.co.uk/itm/DIFFERENTIAL-THERMOSTAT-SOLAR-WATER-HEATING-PUMP-CONTROLLER-INCLUDING-SENSORS-/271862092663?pt=LH_DefaultDomain_3&hash=item3f4c3e5377
thermal immersion
http://www.solaplug.co.uk/TheSolaPlugRange.aspx
http://h2solarshop.eu/epages/950000309.sf/en_GB/?ObjectPath=/Shops/950000309/Products/54322b&ViewAction=ViewProduct
http://h2solarshop.eu/epages/950000309.sf/en_GB/?ObjectPath=/Shops/950000309/Products/54322&ViewAction=ViewProduct
http://h2solarshop.eu/epages/950000309.sf/en_GB/?ObjectPath=/Shops/950000309/Products/54322b&ViewAction=ViewProduct
http://h2solarshop.eu/epages/950000309.sf/en_GB/?ObjectPath=/Shops/950000309/Products/54322&ViewAction=ViewProduct
Subscribe to:
Posts (Atom)