Beispiel #1
0
def fetch_configs():
    db = MyZODB('./Data.fs')
    dbroot = db.dbroot
    price = 0
    count = 0
    key = ''
    secret = ''
    try:
        price = dbroot['last_price']
    except KeyError as e:
        logging.debug(e)
        dbroot['last_price'] = 0  # set to last trade price

    try:
        count = dbroot['sell_count']
    except KeyError as e:
        logging.debug(e)
        dbroot['sell_count'] = 0

    try:
        key = dbroot['api_key']
    except KeyError as e:
        logging.debug(e)
        dbroot['api_key'] = "Your api key"

    try:
        secret = dbroot['api_secret']
    except KeyError as e:
        logging.debug(e)
        dbroot['api_secret'] = "Your api secret"

    transaction.commit()
    db.close()
    return price, count, key, secret
Beispiel #2
0
			def saveKmeans(self,group,centr):
				db = MyZODB('Data.fs')
				dbrootN = db.dbroot
				#temphash = {}

				for index in range(len(centr)):
					dbrootN[index] = {}
					dbrootN[index]['Centroid'] = {}
					dbrootN[index]['Centroid']['nodes'] = {}
					dbrootN[index]['Centroid']['edges'] = {}
					for node in centr[index].nodes:
						dbrootN[index]['Centroid']['nodes'][node] = centr[index].nodes[node]
					for edge in centr[index].edges:
						dbrootN[index]['Centroid']['edges'][edge] = centr[index].edges[edge]
					dbrootN[index]['GraphGroup'] = {}
					for gviewIndex in range(len(group[index])):
						dbrootN[index]['GraphGroup'][gviewIndex] = {}
						dbrootN[index]['GraphGroup'][gviewIndex]['nodes'] = {}
						dbrootN[index]['GraphGroup'][gviewIndex]['edges'] = {}
						for node in group[index][gviewIndex].nodes:
							dbrootN[index]['GraphGroup'][gviewIndex]['nodes'][node] = group[index][gviewIndex].nodes[node]
						for edge in group[index][gviewIndex].edges:
							dbrootN[index]['GraphGroup'][gviewIndex]['edges'][edge] = group[index][gviewIndex].edges[edge]

				#dbrootN = temphash
				#print dbrootN
				transaction.commit()
				db.close()
Beispiel #3
0
			def saveData(self):
				db = MyZODB('Data2.fs')
				dbrootN = db.dbroot
				dbrootN['gviews'] = {}
				dbrootN['InvertedList'] = {}
				for g in self.gSetToMusic:
					dbrootN['gviews'][g] = self.gSetToMusic[g]
				for t in self.InvertedList:
					dbrootN['InvertedList'][t] = self.InvertedList[t]
				transaction.commit()
				db.close()				
Beispiel #4
0
	def loadingMODB(self,DBFilePath):
		db = MyZODB(DBFilePath)
		dbrootN = db.dbroot
		for t in dbrootN['InvertedList']:
			if t == '':continue
			temphash = dbrootN['InvertedList'][t]
			keys = sorted(temphash.iteritems(),key=lambda temphash:temphash[1],reverse=True)
			c = 0
			temphash2 = {}
			for j in keys:
				c += 1
				if c > 1000:break
				temphash2[j[0]] = j[1]
			self.InvertedList[t] = temphash2
		for sl in dbrootN['gviews']:
			self.MusicSet[sl] = self.gview([])
			for node in dbrootN['gviews'][sl]['nodes']:
				self.MusicSet[sl].nodes[node] = dbrootN['gviews'][sl]['nodes'][node]
			for edge in dbrootN['gviews'][sl]['edges']:
				self.MusicSet[sl].edges[edge] = dbrootN['gviews'][sl]['edges'][edge]
		transaction.commit()
		db.close()
		return self.MusicSet,self.InvertedList
Beispiel #5
0
def store_sell_count(count):
    db = MyZODB('./Data.fs')
    dbroot = db.dbroot
    dbroot['sell_count'] = count
    transaction.commit()
    db.close()
Beispiel #6
0
def store_price(price):
    db = MyZODB('./Data.fs')
    dbroot = db.dbroot
    dbroot['last_price'] = price
    transaction.commit()
    db.close()
Beispiel #7
0
# fetch_hosts.py - show hosts in the database

from myzodb import MyZODB
db = MyZODB('./Data.fs')
dbroot = db.dbroot

from mymodel import Host
for key in dbroot.keys():
	obj = dbroot[key]
	if isinstance(obj, Host):
		print "Host:", obj.name
		print "  IP address:", obj.ip, "  Interfaces:", obj.interfaces

db.close()