Appears to work.
Had to reinstall Ubuntu Quickly for upgrade. Removed per error in subprocess.call(..., env) portion 'env'...just remove this 'env' argument where occurring in create.py and run.py files. If you can't get root privileges in gedit (the windows way) to modify the file at this using:
sudo pico /path/to/file/create.py
and so froth
ctrl-x and save as necessary.
Don't forget to examine Porting to gtk3 if you plan on porting any developed/developing code to the newer upcoming OS.
Sunday, March 11, 2012
Saturday, March 10, 2012
The I Dont Blame that Generation for being what it is
The Go Nowhere Generation
Hmm...fitting to the bill here, crashed and burned on a life adventure, burn too much even for some measurable risk, bear conservation kicks in...that simple, don't move unless you need to really...
why make life harder then it need be?!
What pushed people to move and go back then...seems to me, feeling like choices were much limited, and making alternatives a necessity by comparison, if great social movements and wars were a reflection of this.
speculation on why this were so...
As to picking up and going, this is a bit of a psychology and sociology question it seems. Moving away from friends, family, social networks and re inventing a new far away from home, isn't exactly easy for all, even when social technologies have made living abroad or elsewhere in the country easier. Sure if you had means, you might be able to afford child care, or having any other things at once disposal to make due in situations where you might have needed help, but as to Nuclear family alone, it seems a modern industrial invention, people that move in lower socio economic strata face challenges that others in higher brackets don't face, they don't have perhaps as much the resources I might argue, and compensations socially would likely be in order to make amends when setting down roots in a new place.
As to personal example, you move, you figure out the basics like getting a job where you move to, or at least know that not having a company transfer in place and just moving where you like to go rather then choosing on the basis of opportunities provided, means necessarily dealing with something simple like having a local address perhaps for the place that you locally desire working. You might not get hired, for instance, if you made it obvious you were technically homeless, or made it clear you were living out of a motel and so forth, but it really depends I imagine. Sort of personally skirted this by setting up a local P.O. Box. which seemed to work for temporary employment until having had some month to month rental agreement in place...and then transitioned into six month rental agreement terms.
The problems though with living elsewhere when you social network and bailout safety net are limited relatively so...you get by month to month, but even when 30k cuts it for living costs, its not like you are wealthy in a fairly big city, or even modestly saving really well here...I've heard of some living out of cars, just for the purpose of building some sort of savings here as sad as this sounds and this were prior to 2001, imagine its probably the same if not more true today, you might have once been able to swing the mortgage for 100k property purchase, out there, but then you might get locked in, and if you were unlucky at some point to get caught in a housing bubble collapse, you might also be walking away from the property and pretending it never existed with that much water over your head. I was leary buying property back then, and while not building any sort of equity in renting solely, at least provided me some easier emotional let go when the time might have come in leaving as predictably happened to me. It seems, if you got burned on bad financial housing investments, or you were stressing yourself out way too much with water accumulating working any number of part time positions just to keep the water from flooding in on mortgage payments, added to this living hundreds if not thousands of miles away from most family, friends and relatives, social technology only goes so far relative to being in closer physical proximity. I went west, as supposedly I heard others might have for a time, dot com bust caused some fallout in Seattle supposedly, but fortunately I worked in telecommunications which were generally unaffected, but almost took an entry level position with Amazon, and fortunately avoided this...they basically left Seattle within a year or so from the time that I left. Of course, it seems, as I've heard credit markets aren't great, so you move today elsewhere, maybe you are more likely to get scrutinised for credit applications...investing in housing could be as likely less gain in so far as equities acquisitions with a risky move away from old social networks...albeit however rooted in childhood and otherwise unchanged and generally less promising in so far as opportunities provided otherwise, in making new ones. Mostly though the big question when you move elsewhere...umm...this is to say depending on what you do, where you work, you may or may less likely make new social networks...
you work in data entry and generally have little downtime doing it, and generally are expected to do what you do, you might make some acquaintances here and there...and as to the types of positions that are opened up based upon friendships had, well, maybe characteristically and statistically speaking this were lateral in nature in so far as potential for economic mobility. Though depending upon the characteristics of the employer, whether hiring and promoting from within, if you knew something of your employer and they often hired outside for higher level positions, you're chances of vertical mobility internally in the company or corporation you worked for were slim to none... chances are if you were going door to door without a friends referral in this poor economy looking for a better position, and you hadn't known anyone at the referring corporation/company, your chances may diminished for hiring, and the reality of moving to a new location, unless you had some recruitment/internship opportunity line up prior to moving, you may be wasting your time...I decided to move without knowing what I was going to be doing, without having anything lined up, and still fortunately got a job by lucky coincidence, but as to being a long lived opportunity (beyond a few years)...nope.
Read some story awhile back about a man, once chef, turned c.s. major that moved with his family to S.F....of all exorbitantly expensive places to live, puts his wife and kid up in a homeless shelter and ends up sleeping in some bushes around Golden Gate Bridge park...never found out if his plight landed him a job, hope so, but seems remember hearing so much about doctors, engineers making solid middle class wages, holed up an hour or more away from San Francisco and living in a house no bigger then a small car garage....rent may have declined, but even moving to a bigger city where potential opportunities may be greater, doesn't always provide enough relative to living and housing costs.
Of course, knowing people from all around the country might help you if you do decide to move, at least, they might help with a referral, but really, would seem surprising if people were kind enough to extend themselves out more so only knowing you in some digital context, and then not having friends is something of a double edged sword where any number might learn the fine art between wanting and needing friends and so forth...being too needy upsets and bothers people, and not wanting could be estranging and off putting to others. :) Sort of laughable social judgements that exists, if you were typically, resorting to stereo type here, if you were satisfied with life and occupation, all of this might not matter, but whose employment position in today's and age were securely set for life here in America?! Chances are the more people you know might get your foot in the door for some employment opportunity...you'd probably here some career counsellor tell you, lots that get hired, may have had added chance for success simply knowing someone that worked in the company or corporation that such applicant applied for. So as it turns out if you were sitting on your duff, feeling secure at what you were doing for a time, and you didn't bother to socialise much and hard times come your way, someone might help put a word in for you, but it may be tougher if no one really knew you that well...sociological case in point, excursions into new frontiers with mixed population groups the first to go freezing to death: the loners, the last to go...the women in the families. :) Obviously, on aspect of survival in these social settings when times are dire are: well...women have much body fat relative so less likely to freeze to death as quickly literally, but perhaps more telling here (in the pop psych sociology trivia), the women in these setting were more socially resourceful relative to men, and able to manage loss through distributive networks, any stockpiles of food, and likewise, through households had better distributive means of acquiring food...it seems in the modern context, something of lesson could be applied, being the quiet loner doesn't make it easier for you to get by in hard times, or mean that you were merely tougher to survive at that, at least you may be tougher relatively so in some manner, but the odds may be stacked against you...generally if you were bear, you might be better off here, a wolf...probably not much of a go.... And if someone else in the household had some occupation, or you had savings built up for some temporary crisis however such may have taken place, you might be able to swing the downtimes, with a savings cushion. If you were stressed about being on time everyday for work, time obsessed and so forth and you were the sole wage earner in the household, having moved half way across the country and hadn't made much of a social network where you moved to, would all that stress, headache, lost sleep, be worth the move?! Hmm...guess its perspective here...a city seemingly full opportunity socially speaking, may be as lonely as desert island, if you were constantly searching for a place that were paradise fitting to some idea, you might never find it, and perhaps all the ails, stress and worry of finding something that never really existed might have been better extinguished with the decision of giving up on an idea that a better world existed elsewhere relative the world that you came from...
In any event, instead of encouraging movement, what about local sustainability?!
Roadtrips are okay, gas prices permitting.
Hmm...fitting to the bill here, crashed and burned on a life adventure, burn too much even for some measurable risk, bear conservation kicks in...that simple, don't move unless you need to really...
why make life harder then it need be?!
What pushed people to move and go back then...seems to me, feeling like choices were much limited, and making alternatives a necessity by comparison, if great social movements and wars were a reflection of this.
speculation on why this were so...
As to picking up and going, this is a bit of a psychology and sociology question it seems. Moving away from friends, family, social networks and re inventing a new far away from home, isn't exactly easy for all, even when social technologies have made living abroad or elsewhere in the country easier. Sure if you had means, you might be able to afford child care, or having any other things at once disposal to make due in situations where you might have needed help, but as to Nuclear family alone, it seems a modern industrial invention, people that move in lower socio economic strata face challenges that others in higher brackets don't face, they don't have perhaps as much the resources I might argue, and compensations socially would likely be in order to make amends when setting down roots in a new place.
As to personal example, you move, you figure out the basics like getting a job where you move to, or at least know that not having a company transfer in place and just moving where you like to go rather then choosing on the basis of opportunities provided, means necessarily dealing with something simple like having a local address perhaps for the place that you locally desire working. You might not get hired, for instance, if you made it obvious you were technically homeless, or made it clear you were living out of a motel and so forth, but it really depends I imagine. Sort of personally skirted this by setting up a local P.O. Box. which seemed to work for temporary employment until having had some month to month rental agreement in place...and then transitioned into six month rental agreement terms.
The problems though with living elsewhere when you social network and bailout safety net are limited relatively so...you get by month to month, but even when 30k cuts it for living costs, its not like you are wealthy in a fairly big city, or even modestly saving really well here...I've heard of some living out of cars, just for the purpose of building some sort of savings here as sad as this sounds and this were prior to 2001, imagine its probably the same if not more true today, you might have once been able to swing the mortgage for 100k property purchase, out there, but then you might get locked in, and if you were unlucky at some point to get caught in a housing bubble collapse, you might also be walking away from the property and pretending it never existed with that much water over your head. I was leary buying property back then, and while not building any sort of equity in renting solely, at least provided me some easier emotional let go when the time might have come in leaving as predictably happened to me. It seems, if you got burned on bad financial housing investments, or you were stressing yourself out way too much with water accumulating working any number of part time positions just to keep the water from flooding in on mortgage payments, added to this living hundreds if not thousands of miles away from most family, friends and relatives, social technology only goes so far relative to being in closer physical proximity. I went west, as supposedly I heard others might have for a time, dot com bust caused some fallout in Seattle supposedly, but fortunately I worked in telecommunications which were generally unaffected, but almost took an entry level position with Amazon, and fortunately avoided this...they basically left Seattle within a year or so from the time that I left. Of course, it seems, as I've heard credit markets aren't great, so you move today elsewhere, maybe you are more likely to get scrutinised for credit applications...investing in housing could be as likely less gain in so far as equities acquisitions with a risky move away from old social networks...albeit however rooted in childhood and otherwise unchanged and generally less promising in so far as opportunities provided otherwise, in making new ones. Mostly though the big question when you move elsewhere...umm...this is to say depending on what you do, where you work, you may or may less likely make new social networks...
you work in data entry and generally have little downtime doing it, and generally are expected to do what you do, you might make some acquaintances here and there...and as to the types of positions that are opened up based upon friendships had, well, maybe characteristically and statistically speaking this were lateral in nature in so far as potential for economic mobility. Though depending upon the characteristics of the employer, whether hiring and promoting from within, if you knew something of your employer and they often hired outside for higher level positions, you're chances of vertical mobility internally in the company or corporation you worked for were slim to none... chances are if you were going door to door without a friends referral in this poor economy looking for a better position, and you hadn't known anyone at the referring corporation/company, your chances may diminished for hiring, and the reality of moving to a new location, unless you had some recruitment/internship opportunity line up prior to moving, you may be wasting your time...I decided to move without knowing what I was going to be doing, without having anything lined up, and still fortunately got a job by lucky coincidence, but as to being a long lived opportunity (beyond a few years)...nope.
Read some story awhile back about a man, once chef, turned c.s. major that moved with his family to S.F....of all exorbitantly expensive places to live, puts his wife and kid up in a homeless shelter and ends up sleeping in some bushes around Golden Gate Bridge park...never found out if his plight landed him a job, hope so, but seems remember hearing so much about doctors, engineers making solid middle class wages, holed up an hour or more away from San Francisco and living in a house no bigger then a small car garage....rent may have declined, but even moving to a bigger city where potential opportunities may be greater, doesn't always provide enough relative to living and housing costs.
Of course, knowing people from all around the country might help you if you do decide to move, at least, they might help with a referral, but really, would seem surprising if people were kind enough to extend themselves out more so only knowing you in some digital context, and then not having friends is something of a double edged sword where any number might learn the fine art between wanting and needing friends and so forth...being too needy upsets and bothers people, and not wanting could be estranging and off putting to others. :) Sort of laughable social judgements that exists, if you were typically, resorting to stereo type here, if you were satisfied with life and occupation, all of this might not matter, but whose employment position in today's and age were securely set for life here in America?! Chances are the more people you know might get your foot in the door for some employment opportunity...you'd probably here some career counsellor tell you, lots that get hired, may have had added chance for success simply knowing someone that worked in the company or corporation that such applicant applied for. So as it turns out if you were sitting on your duff, feeling secure at what you were doing for a time, and you didn't bother to socialise much and hard times come your way, someone might help put a word in for you, but it may be tougher if no one really knew you that well...sociological case in point, excursions into new frontiers with mixed population groups the first to go freezing to death: the loners, the last to go...the women in the families. :) Obviously, on aspect of survival in these social settings when times are dire are: well...women have much body fat relative so less likely to freeze to death as quickly literally, but perhaps more telling here (in the pop psych sociology trivia), the women in these setting were more socially resourceful relative to men, and able to manage loss through distributive networks, any stockpiles of food, and likewise, through households had better distributive means of acquiring food...it seems in the modern context, something of lesson could be applied, being the quiet loner doesn't make it easier for you to get by in hard times, or mean that you were merely tougher to survive at that, at least you may be tougher relatively so in some manner, but the odds may be stacked against you...generally if you were bear, you might be better off here, a wolf...probably not much of a go.... And if someone else in the household had some occupation, or you had savings built up for some temporary crisis however such may have taken place, you might be able to swing the downtimes, with a savings cushion. If you were stressed about being on time everyday for work, time obsessed and so forth and you were the sole wage earner in the household, having moved half way across the country and hadn't made much of a social network where you moved to, would all that stress, headache, lost sleep, be worth the move?! Hmm...guess its perspective here...a city seemingly full opportunity socially speaking, may be as lonely as desert island, if you were constantly searching for a place that were paradise fitting to some idea, you might never find it, and perhaps all the ails, stress and worry of finding something that never really existed might have been better extinguished with the decision of giving up on an idea that a better world existed elsewhere relative the world that you came from...
In any event, instead of encouraging movement, what about local sustainability?!
Roadtrips are okay, gas prices permitting.
Sunday, March 4, 2012
Example data tree parser (for nested dictionaries) in Python
import datetime class Workdictmanager: def __checkinitworkdict(self, sessiontime): check = False if 'workdict' in sessiontime: check = True self.workdict = sessiontime['workdict'] return check def putWorkdict(self, sessiontime): return self.__checkinitworkdict(sessiontime) ## self.workdict = sessiontime['workdict'] def qwordCheck(self, qword): check = False if qword in self.workdict: check = True return check def addWorkvals(self, qword, valtup): #here valtup is expected in list or tuple form #this is an ordered set, (akey, score, att) if qword in self.workdict: self.qworddir = self.workdict[qword] self.qworddir['score'] += valtup[1] self.qworddir['totalattempts'] += valtup[2] self.workdict[qword] = self.qworddir else: self.qworddir = {} self.qworddir['answer'] = valtup[0] self.qworddir['score'] = valtup[1] self.qworddir['totalattempts'] = valtup[2] self.workdict[qword] = self.qworddir def retrieveDictval(self, qword, dirkey): self.qworddir = self.workdict[qword] return self.qworddir[dirkey] def retrieveWorkdict(self): return self.workdict def __init__(self): self.workdict = {} class Statsmanager: #what is the difference between saveStat and put, puts an already #recorded stat session into the Statmanager class object whereas # saveStat saves an individual stat in the class object def __checkinitstats(self, sessiontime): check = False if 'stats' not in sessiontime: self.save() else: check = True self.stats = sessiontime['stats'] self.totalwords = self.stats['totalwords'] self.totalcorrect = self.stats['totalcorrect'] self.totalincorrect = self.stats['totalincorrect'] return check def save(self): self.stats['totalwords'] = self.totalwords self.stats['totalcorrect'] = self.totalcorrect self.stats['totalincorrect'] = self.totalincorrect def putStats(self, sessiontime): return self.__checkinitstats(sessiontime) ## self.stats = sessiontime['stats'] def addStats(self, valtup): self.stats['totalwords'] += valtup[0] self.stats['totalcorrect'] += valtup[1] self.stats['totalincorrect'] += valtup[2] def saveStat(self, statkey, value): if statkey == 'totalwords': self.totalwords = value self.stats['totalwords'] = self.totalwords #int value elif statkey == 'totalcorrect': self.totalcorrect = value self.stats['totalcorrect'] = self.totalcorrect #int value elif statkey == 'totalincorrect': self.totalincorrect = value self.stats['totalincorrect'] = self.totalincorrect #int value def retrieveStat(self, statkey): stat = 0 if statkey == 'totalwords': stat = self.stats['totalwords'] elif statkey == 'totalcorrect': stat = self.stats['totalcorrect'] elif statkey == 'totalincorrect': stat = self.stats['totalincorrect'] return stat def retrieveStats(self): return self.stats def __init__(self): self.stats = {} self.totalwords = 0 self.totalcorrect = 0 self.totalincorrect = 0 self.stats['totalwords'] = self.totalwords self.stats['totalcorrect'] = self.totalcorrect self.stats['totalincorrect'] = self.totalincorrect class Sessioncachemanager: def addStats(self, statstup): self.statsmngr.addStats(statstup) def retrieveStats(self): return self.statsmngr.retrieveStats() def retrieveWork(self): return self.workdictmngr.retrieveWorkdict() def retrieveSessiontimeelapsed(self): return self.sessiontimeelapse def retrieveSessiontimefromlast(self): return self.sessiontimefromlast def addWorkvals(self, qword, workvalstup): self.workdictmngr.addWorkvals(qword, workvalstup) def __checkSessionTime(self, sessiontimekey): check = False if sessiontimekey in self.session: check = True return check def __recordEndSession(self): self.__sessionrecord(False) def __recordBeginSession(self): self.__sessionrecord(True) def clearSession(self, time): #measure current time then compare timedelta from now #to all session datetime objects, then convert this # to total seconds those exceeding in total seconds #will be keys removed from the session. #The variable 'time' is measured in seconds currenttime = datetime.datetime.now() timestamps = list(self.session.keys()) if type(time) == str: if time == 'All': for timestamp in timestamps: del self.session[timestamp] elif type(time) == int: for timestamp in timestamps: timedelt = currenttime - timestamp timedeltsec = timedelt.total_seconds() if time > timedeltsec: del self.session[timestamp] def newSession(self, userdict): self.session = userdict['session'] self.__recordBeginSession() self.session[self.sessionbegin] = self.sessiontime self.statsmngr = Statsmanager() self.workdictmngr = Workdictmanager() def putSessiontime(self, sessiontimekey, userdict): self.session = userdict['session'] if self.__checkSessionTime(sessiontimekey): self.sessiontime = self.session[sessiontimekey] self.statsmngr.putStats(self.sessiontime) self.workdictmngr.putWorkdict(self.sessiontime) else: print('Session Time value does not exist!') def putSession(self, userdict): self.session = userdict['session'] def retrieveSessiontimekeys(self): return list(self.session.keys()) def saveSession(self): ## self.sessiontime = {} ## self.statsmngr.putStats(self.sessiontime) ## self.workdictmngr.putWorkdict(self.sessiontime) #calls from stats class stats = self.statsmngr.retrieveStats() self.sessiontime['stats'] = stats #call from workdict workdict = self.workdictmngr.retrieveWorkdict() self.sessiontime['workdict'] = workdict self.__recordEndSession() print('session begin ',self.sessionbegin) print('session end ', self.sessionend) self.__sessiontimeelapse() self.__sessiontimeelapsefromlast() self.sessiontime['sessiontime'] = self.sessiontimeelapse self.session[self.sessionbegin] = self.sessiontime sessionuserdict = self.session self.sessionlast = self.__recordTime() return sessionuserdict def retrieveSession(self, userdict): self.session = userdict['session'] def __recordTime(self): return datetime.datetime.now() def __sessiontimeelapse(self): #subtraction of timedate object yields timedelta object self.sessiontimeelapse = self.sessionend - self.sessionbegin def __sessiontimeelapsefromlast(self): self.sessiontimefromlast = self.sessionend - self.sessionlast def __sessionrecord(self, flag): #true flag records begin session while false flag records end stamp if flag: self.sessionbegin = self.__recordTime() self.sessionlast = self.__recordTime() else: self.sessionend = self.__recordTime() def __init__(self): self.session = {} self.sessiontime = {} self.sessiontimeelapse = 0 self.statsmngr = Statsmanager() self.workdictmngr = Workdictmanager() class Overallcachemanager: def __checkinitoverallstats(self, check): if not check: self.overall['stats'] = self.statsmngr.retrieveStats() def __checkinitoverallworkdict(self, check): if not check: self.overall['workdict'] = {} def addStats(self, statstup): self.statsmngr.addStats(statstup) def clearOverall(self, typeflag): if typeflag == 'All': self.statsmngr = Statsmanager() self.workdictmngr = Workdictmanager() elif typeflag == 'Stats': self.statsmngr = Statsmanager() elif typeflag == 'Workdict': self.workdictmngr = Workdictmanager() def retrieveStats(self): return self.statsmngr.retrieveStats() def retrieveWork(self): return self.workdictmngr.retrieveWorkdict() def addWorkvals(self, qword, workvalstup): self.workdictmngr.addWorkvals(qword, workvalstup) def newOverall(self): self.overall = {} self.statsmngr = Statsmanager() self.workdictmngr = Workdictmanager() def save(self): self.overall['stats'] = self.statsmngr.retrieveStats() self.overall['workdict'] = self.workdictmngr.retrieveWorkdict() return self.overall def put(self, userdict): if 'overall' in userdict: print('hitting if overall in userdict') self.overall = userdict['overall'] if 'sessiontime' not in self.overall: self.overall['sessiontime'] = datetime.timedelta() check = self.statsmngr.putStats(self.overall) self.__checkinitoverallstats(check) check = self.workdictmngr.putWorkdict(self.overall) self.__checkinitoverallworkdict(check) else: userdict['overall'] = {} self.overall = {} self.overall['sessiontime'] = datetime.timedelta() self.statsmngr = Statsmanager() self.workdictnmngr = Workdictmanager() def addSessiontime(self, timedelt): self.overall['sessiontime'] += timedelt def retrieveSessiontime(self): return self.overall['sessiontime'] def __init__(self): self.overall = {} self.overall['sessiontime'] = datetime.timedelta() self.statsmngr = Statsmanager() self.workdictmngr = Workdictmanager() class Cachemanager: def addSessionstatdat(self, statdat): self.sessioncache.addStats(statdat) def addSessionworkdat(self, qword, workdat): #workdat self.sessioncache.addWorkvals(qword, workdat) def addOverallstatdat(self, statdat): self.overallcache.addStats(statdat) def addOverallworkdat(self, qword, workdat): self.overallcache.addWorkvals(qword, workdat) def addOverallsessiontime(self, sessiontimeelapsed): self.overallcache.addSessiontime(sessiontimeelapsed) def clearOverall(self, typeflag): #'typeflag' is a variable set to one of the following: #'All', 'Stats', or 'Workdict' self.overallcache.clearOverall(typeflag) def clearSession(self, time): self.sessioncache.clearSession(time) def putSession(self): self.sessioncache.putSession(self.user) def putSessiontime(self, sessiontime, user): #sessiontime is a datetime object self.sessioncache.putSessiontime(sessiontime, user) def retrieveSessiontimekeys(self): return self.sessioncache.retrieveSessiontimekeys() def savereturnSession(self): self.user['session'] = self.sessioncache.saveSession() totalsessiontime = self.sessioncache.retrieveSessiontimefromlast() self.overallcache.addSessiontime(totalsessiontime) def savereturnOverall(self): self.user['overall'] = self.overallcache.save() def retrieveSessionwork(self): return self.sessioncache.retrieveWork() def retrieveSessionstats(self): return self.sessioncache.retrieveStats() def retrieveOverallstats(self): return self.overallcache.retrieveStats() def retrieveOverallwork(self): return self.overallcache.retrieveWork() def newSession(self): self.sessioncache.newSession(self.user) def __checkandinituserdat(self): if 'session' not in self.user: self.user['session'] = {} if 'overall' not in self.user: self.user['overall'] = {} def __init__(self, userdat, newSessionflag): self.user = userdat self.__checkandinituserdat() self.overallcache = Overallcachemanager() self.sessioncache = Sessioncachemanager() self.overallcache.put(self.user) if not newSessionflag: self.sessioncache.putSession(self.user) else: self.sessioncache.newSession(self.user)
Here is my userdata tree parser used in conjuction to the previous shelve object read/write interface class.
Data tree can generally be expressed as follows:
user session data, dictionary keys are 'session'>sessiondatetime
and 'Overall' subkeys of each are:
'workdict' > qword > 'answer' > akey > 'score' > score(int)
> 'totalattempts'> att(int)
'stats' > 'totalwords' > totalwords(int)
> 'totalcorrect' > totalcorrect(int)
> 'totalincorrect' > totalincorrect(int)
'sessiontime' > timespent(int min)
Descending from top to bottom in order in so far as program structure, handlers on data tree starting at leaf node and then descending to parent node of all data trees,
thus the Cachemanager class represents the top of the data tree hierarchy and it is through this class that all subsequent data handling assignments are received and transmitted through the respective chain of class above it. Also it is worth noting excepting the child leaf node classes, namely, workdictmanager and statsmanager classes above, all parent classes initialise and transmit data to a respective data child classmanager for such data level.
The simplest way of thinking about this is comes by the following example:
a = { b: dictionary of b, c: dictionary of c}
dictionary of b = {d: dictionary of d, e: dictionary of e}
dictionary of c = {f: dictionary of f, g: dictionary of g}
Here, the dictionary a would have its data class handler which controls the passing of data to all embedded dictionaries inside a...this means data sent to b, c, d, e, f, and g.
The class handler of dictionary a would decide and appropriately send to data in the tree to:
- b if data needed to be sent/received from child leaf node d or e,
or
-c if data needed to be sent/received from child leaf node f or g.
In turn data sent or received according to design structure above, passes data to the handler of b or c respectively, and the handlers of b or c, in turn pass data to the handlers of d, e, f, or g as required.
Thus each trunk/branch/leaf all have respective class data handlers for their respective positions on the data tree in this database parsing model.
In the case of more complex data trees, class handling models of this type become more complex at the top level hierarchies, in terms of the potential function handling possibilities in so far as data pathing structures here.
In conjunction to the previous posting regarding shelve object storage of both user and user data...I can in one read to permanent storage action, read all the user's given data stored on disk, in one call, and pull up all of the user's relevant history in so far as previous interactions. I minimise the write to calls for the user's present session use, by only writing all relevant data to be added, once the user's session is finalised which occurs either at user account change or at program termination. Thus maintaining higher read/write efficiency in doing so...i.e., avoiding numerous disk reads and writes to get at the same sets of data.
User shelve object database example in Python
import os import shelve class Userdata: def closeUserfile(self): self.userdatafile.close() def saveUser(self, user, userdata): self.user = user self.__checkreadFile() if self.__verifyUser(): self.userdatafile[self.user] = userdata print('User data saved.') self.userdatafile.close() def saveUserdata(self, userdata): self.__checkreadFile() #self.userdatafile[self.user] = userdata if self.__verifyUser(): self.userdatafile[self.user] = userdata print('User data saved.') self.userdatafile.close() def addUser(self, user): self.user = user self.__checkreadFile() usercheck = self.__verifyUser() if not usercheck: self.userdatafile[self.user] = {} print('User added.') else: print('User already exists.') return usercheck self.userdatafile.close() def retrieveUser(self, user): self.user = user self.__checkreadFile() if self.__verifyUser(): self.userdata = self.userdatafile[self.user] self.userdatafile.close() return self.userdata def retrieveUsername(self): return self.user def retrieveUserlist(self): userlist = [] self.__checkreadFile() for user in self.userdatafile: if not user == 'High Score': userlist.append(user) self.userdatafile.close() return userlist def isUserdatempty(self): check = False self.__checkreadFile() if len(self.userdatafile) == 0: check = True self.userdatafile.close() return check def returnFirstuser(self): self.__checkreadFile() userlist = list(self.userdatafile.keys()) firstuserkey = userlist[0] self.userdatafile.close() return [firstuserkey, self.userdatafile[firstuserkey]] def __verifyUser(self): check = False if self.user in self.userdatafile: check = True return check def verifyUser(self, username): check = False self.__checkreadFile() if username in self.userdatafile: check = True self.userdatafile.close() return check def __readFile(self): self.userdatafile = shelve.open(self.pathfile, 'w') def __createFile(self): self.userdatafile = shelve.open(self.pathfile, 'n') def __checkreadFile(self): file = '' if os.name == 'nt': file = '\\yourdatafilenamehere' elif os.name == 'posix': file = '/yourdatafilenamehere' self.pathfile = self.path+ file if os.access(self.pathfile, os.F_OK): if os.access(self.pathfile, os.R_OK): if os.access(self.pathfile, os.W_OK): self.__readFile() else: self.__createFile() else: self.__createFile() else: self.__createFile() ## def checkUser(self): ## ## self.__checkreadFile() ## self.__verifyUser() def __init__(self): self.path = os.getcwd() self.user = '' #self.__checkreadFile()
Something of an alternative shelve object database storage class alternative code offering outside the CouchDB. I'd mention some issues experienced with Python shelve objects:
- Heavy read write loads to shelve objects aren't good at least with respect read write from permanent (disk based) memory storage. Thus I've typically housed much of the data in such a way that reading from disk ensures likely all the information (in terms of transient storage) will be there to minimise read/write callbacks. Thus I actually wrote a database program which parses additionally embedded dictionary trees for reading such data. In effect, you hadn't need develop something like an sql database program to do this, since the pertinent data that you needed for your program may remain exact in so far as object data were concerned. You just need to make sure that you have it structured, in this case, in a way, so that your data reader knows where to find the data in the tree hierarchy in doing so. If you need some alternate method for storing dynamic data to a given database, you might consider using python's sql module interfaces, this fyi provides some basic sql code examples. I'll post my tree structure interface here probably in a day or so, that at least provides how an extensive data tree process handling might look like.
-You may notice above, generally after reading calls to a shelve object file, such shelve object file is closed. This is done per recommends of python, and as I've experienced, if you don't track closing and opening, errors can result when attempting to re open an already open file or reading from a closed file. Thus, wise to make sure that routine orderliness applies here.
In the __checkreadFile() function call above, the program attempts to verify that the datafile exists in the installation directory path...this installation directory path is established by the command os.getcwd() . If the file exists it reads, otherwise, it needs to be created.
Generally idea here is that a user data can be stored or retrieved, and user key information can be searched for, and lists of users can be furnished through this given class .
Ubuntu 11.10 experiences review in brief over past year
When Ubuntu 11.04 were released in previous year, I hadn't taken to the complaints about 11.04 and 11.10 unity interface in terms of conceived stylisation. Here visual interface design conceived in providing more so prominent and understood visual navigation design interfaces relative to previous traditional interface structures. However, minor annoyances still seem present, scroll bars, outside of default design settings found say in Firefox browsers, seem more difficult in managing, while philosophy of visual interface minimalism seems more so, apparently the version of Firefox installed in Ubuntu, felt visually the element of the scroll bar shouldn't be taken away (even if facilitating in a focus/transient based manner), and I believe they are right here. Likewise I had looked forward to as an alternative to windows desktop environment, being rewarded with the opportunity to take advantage of newer operating system releases alongside the advantages that any open source community might offer relatively so, it seems this were true. However, I may suggest, at times, the focus in release cycles concerning progress, in so far as software interoperability and software centre maintenance appear at odds with the adherence to reliability. Several occasions found myself, un installing software that neither seemed to work in the ways that once suggested, and this could be something of a downside to the Ubuntu experience if having expectation that software should work in future release cycles. This being said, this isn't to say that operability owing to significant progress were always true, but it could be something of problem outside operability conservation in applied changes to os design.
Despite this, however, Ubuntu still maintains some appeal for me. I hadn't been exactly the user, ever so dependent upon any specific base source of software, mostly at the moment development oriented, and it seems any software typically in the archives, that I hadn't noticed previously but suddenly noticed not exactly working, weren't exactly loss here, and one could offer, maybe it weren't the job of Ubuntu as a whole to maintain any number of software whose maintainers long since abandoned as a result of any number of reasons. Hard for me to judge the level of open source software development at the moment, however. Core programs that I like continue to generally work, and the operating system has overall been reliable enough, and then mostly in terms of absence of functionality here, has been inspirational to development, one might wonder whether survival shows could be produced here...how to create the program you need in Ubuntu if it doesn't exactly exist...at least if Ubuntu could make their Quickly development series package even more hands on and friendly, it might not matter whether maintainers of old defunct software eventually disappear into the fray, someone might create something just as good if not better in a flash!
Despite this, however, Ubuntu still maintains some appeal for me. I hadn't been exactly the user, ever so dependent upon any specific base source of software, mostly at the moment development oriented, and it seems any software typically in the archives, that I hadn't noticed previously but suddenly noticed not exactly working, weren't exactly loss here, and one could offer, maybe it weren't the job of Ubuntu as a whole to maintain any number of software whose maintainers long since abandoned as a result of any number of reasons. Hard for me to judge the level of open source software development at the moment, however. Core programs that I like continue to generally work, and the operating system has overall been reliable enough, and then mostly in terms of absence of functionality here, has been inspirational to development, one might wonder whether survival shows could be produced here...how to create the program you need in Ubuntu if it doesn't exactly exist...at least if Ubuntu could make their Quickly development series package even more hands on and friendly, it might not matter whether maintainers of old defunct software eventually disappear into the fray, someone might create something just as good if not better in a flash!
Thursday, March 1, 2012
Little bit of a ramble here
Being a reductionist in life isn't always fruitful one might imagine...leads to a bit of arrogance and what not in judgement.
In any event there's always the barrage of tabloid UFO guided by Hitler (or vice versa, who really knows wasn't paying enough attention there) materials on the Green channel, the history channel and the science channel at times for that matter...but recently its morphed into popular titles such as UFO at the bottom of the ocean...hehehe really amusing, and hard really with marketing over saturation as exists at times to solely be perceived as really representing excitement to viewer interests...but more so probably designed to get some sort of reaction. Laughing, hmmm, okay crypto obsession lead to its most rational searching of irrational disorder ends...hmm teasing a bit, you like the movie Pi?
Apparently though as of recent, what seemingly makes the rounds of what is hot on Google+ are any number of crypto spate of messages perhaps if there were an intended embedded message here could seem more transparent relatively so, amusing one's here something to the effect, 'Either you love bacon, or you are wrong.' hmm...hard to see the world driven solely into clearly divided oppositions such as this, at least something ironic seems to come of the manner of speech conveyed about the philosophies and freedoms that apparently should exist in the world and the differences therein in practice to living that seem contrary to this at times.
Watched the cycling tour of Oman on television recently, although hadn't seen 'Burn notice' airing as of recent...
honestly had something of laugh at um, some crypto zoology parody I watched on television sometime ago...can't remember the name of the show, too lazy to look it up right now.
Type casting issue apparent in pygtk programming work
Something interesting when working between widgets in pygtk here, integers may according to widget's referring container may convert these values to floats or some type of numeric cast, thus neither preserving original type assignment. Sort of important since type casting issues, may less commonly be noticed in python owing to the loss of formalities in variable object declarations. One example of this is can be represented in one line where a = 1, and the next line where a = 1.0. The variable a is represented as integer in one line, while in the subsequent line is represented as a float. Further example, assigning integer values into spinboxes leads to the result of a type casting transformation to (double, float type) an associated gtkadjustment container. Upon calling reference back to such widget container without having utilised a type cast transformation back to an originating format type, having stored such value for purposes of memory, could have effects down the road in so far as storage and retrieval later. For example, ran into this problem with regards to initialisation outputs into type cast written strings, however control statement breaking flow of written output to integer types would mean the loss of output data for once integer types now represented as floats, doubles, or other numeric types.
Thus moral in story here, pay attention to type casting when passing data between widget data storage containers in pygtk.
Subscribe to:
Posts (Atom)
Oblivion
Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...
-
For starters, as I've seen (pardon my ignorance if I am incorrect), it seems a common way to use path based animated motion for objects...
-
I've looked through a series of web sites on this topic, any number of these ranging in various degrees of technical information, but...
-
Okay so if you read into python scripting examples of moving vertices around in Blender, it seems whether using a bpy.context or bpy.data c...