Problem with pickle and restarting a program

2014-03-19 Thread Peace
In my GUI, the user enters two values: cellNumber(Integer) and 
SerialNumber(String)

I have the following piece of code in my view/controller:

The following function is called after the user enters the 
cellnumber and serial number##
def ListenForDetails(status):
cellNumber = status[0]
SerialNumber = status[1]
ModelInfo().CellList[cellNumber].receiveSerialNumber(SerialNumber)

--In my controller thread-
class Controller(Thread):
def __init__(self):
Thread.__init__(self)
self.start()

def run(self):
global SynchronizationVariable
while SynchronizationVariable != 1:
time.sleep(0.01)
while 1:
StateChanged = False
for cells in ModelInfo().CellList:
rc = cells.PollCells()
if rc == 0:
StateChanged = True
if StateChanged:
ModelInfo().save()
time.sleep(1)

---In my model.py 
script-

class CellInfo(): #This class encapsulates all the information present in a cell
def __init__(self,cellNo):
self.SerialNo = ""
self.cellNo = cellNo

def receiveSerialNumber(self, SerialNumber):
self.SerialNo = SerialNumber

def PollCells(self):
RC = self.StateMachine[self.CurrentState](self)
return RC

...all state machine functions here...


"""Model Info below"""
class ModelInfo(): #This class creates a list of cells.
def __init__(self):
print("Setting up a list of cells to iterate on")
self.CellList = [] #List of all the cell Objects
for index in xrange(0,24):
print(self.CellList)
self.CellList.append(CellInfo(index))

def save(self):
with open("RestoreInfo.p", "wb") as f:
pickle.dump(self,f)

Model = ModelInfo() #Constructs an empty model

"""IN MAIN (In the controller script)"""
if __name__ == '__main__':
if os.path.isfile( "RestoreInfo.p" ):
with open("RestoreInfo.p", "rb") as f:
model = pickle.load( f );
else:
model = model.ModelInfo();


The serial number field always remains empty even though I enter from the GUI 
and the receiveSerialNumber function is called and I explicitly initialize it 
to the variable in the model.
I'm trying to save the state of the program so that next time I open the 
application it resumes from where it left off. The problem is when I restart 
the application, the serial number is empty. What am I doing wrong here? 
Whenever I get a change in state (the RC value), I pickle and save to a file 
(restoreinfo.p). When I restart the application, the serial number is no longer 
there even though I enter it. Could you please let me know what is going wrong? 
Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with pickle and restarting a program

2014-03-20 Thread peace
On Thursday, March 20, 2014 1:20:03 AM UTC-7, dieter wrote:
> Peace <> writes:
> 
> > ...
> 
> > The serial number field always remains empty even though I enter from the 
> > GUI and the receiveSerialNumber function is called and I explicitly 
> > initialize it to the variable in the model.
> 
> > I'm trying to save the state of the program so that next time I open the 
> > application it resumes from where it left off. The problem is when I 
> > restart the application, the serial number is empty. What am I doing wrong 
> > here? Whenever I get a change in state (the RC value), I pickle and save to 
> > a file (restoreinfo.p). When I restart the application, the serial number 
> > is no longer there even though I enter it. Could you please let me know 
> > what is going wrong? Thank you.
> 
> 
> 
> You may want to use debugging to determine what goes on in detail.
> 
> 
> 
> There are commercial debuggers with a graphical user interface
> 
> (maybe even free ones). Python comes with a simple command line
> 
> debugger ("pdb").

I tried doing that. I still could not figure out what was wrong. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Issues Download the Latest Version of Python Programming Language

2020-07-23 Thread Ejiofor Chidinma Peace
Dear Sir/Madam,
I trust this email finds you well.

I have been having issues downloading the latest version of Python
programming Language on my PC (windows 10 operating system). Kindly assist
in resolving this issue at your earliest convenience.

Looking forward to hearing from you soon.

Yours sincerely,
Ejiofor, Chidinma Peace.
-- 
https://mail.python.org/mailman/listinfo/python-list