Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
Ok, and just tested MySQLdb connection to both XAMPP server instance on 
same machine, as well as slightly remote connection to other machine over 
wifi, and same error - so, seems issue is invoked/caused by MySQLdb 
connection closing - if just put process to sleep for 30 seconds, nothing 
happens, but, the moment I in fact try to then just close the connection, 
that's when error dialogue immediately pops up.


Sorry - should also have mentioned the connection, cursor, etc. ec. all work 
fine under normal python interpreter, but anyway.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
Ok, and just tested MySQLdb connection to both XAMPP server instance on same 
machine, as well as slightly remote connection to other machine over wifi, 
and same error - so, seems issue is invoked/caused by MySQLdb connection 
closing - if just put process to sleep for 30 seconds, nothing happens, but, 
the moment I in fact try to then just close the connection, that's when 
error dialogue immediately pops up.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Jacob Kruger" 

To: "Dennis Lee Bieber" 
Cc: 
Sent: Tuesday, January 13, 2015 8:37 PM
Subject: Re: Python 2.7, on windows7 64 bit development machine, 
inconsistent issue on similar machines




See answers below.

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Dennis Lee Bieber" 




The very first hit /I/ get is:
https://social.technet.microsoft.com/Forums/windows/en-US/3932e3eb-c034-4eb7-aa06-4a0a8e6ea493/fault-module-namestackhash0a9e



Played around with data expraction policy changes/settings now, and didn't 
make it change behaviour.







 s_host = str(d_mysql["host"])
 s_user = str(d_mysql["user"])
 s_pass = str(d_mysql["password"])
 s_db = self.s_target_value


ONE: Have you confirmed all of these are coming in correctly

Yes - that mysql.set pickle dump is just a way of storing some string 
values relating to mysql server connection to sort of hide it from an 
end-user, but, yes, the values work fine in that sense.



 cn = MySQLdb.connect(s_host, s_user, s_pass, s_db)
 if cn:
   cn.autocommit = True


TWO-A: you've turned on autocommit here, yet...


Sorry - that was sort of left-over from when was trying to make sure that 
other parts were happening/working - along with trying out specific commit 
call lower down - have tried taking eitehr of them out one by one, to see 
if made a difference, but, no-go.





   cur = cn.cursor()
   i_struct = 0
   i_data = 0
   f = open(self.s_sql_struct_file, "rb")
   s = f.read()
   f.close()
   l_struct = s.split(";")


THREE-A: here you split some string on semicolons, just to...


   f = open(self.s_sql_data_file, "rb")
   s = f.read()
   f.close()
   l_data = unidecode(s).split(";")
   l_struct_errors = []
   l_data_errors = []
   i_start_time = int(time.time())
   s_status = "/{0} structs".format(str(len(l_struct)))
   for I in range(len(l_struct)):


Very UN-Pythonic...


I know - that was also since originally used this code in a sort of GUI 
version, and meant to use one by one counter to update status bar text at 
sort of intervals of 10 records, to let guys track progress - but, FWIW, 
it seemed to overload my screen reader with too many changes, partly since 
some of these collections of insert statements are processing over 4 
record insertions - not currently with test data, but, some of the other 
test database files I used were operating in that region of the number of 
data record numbers. Have taken that part out again now.




for a_struct in l_struct:
# do stuff with a_struct directly, no indexing into l_struct


 try:
   i_struct = I
   if str(l_struct[I]).strip() != "": res = 
cur.execute(l_struct[I] + ";")


THREE-B: ... reappend the semicolon here... which probably isn't needed
-- cur.execute() assumes, as I recall, that the provided argument is a
complete statement; unlike a command line interface where the semicolon 
is

needed to tell the CLI that the statement is complete and can be sent to
the DBMS for processing.

And very confusing names... l_struct and i_struct, where the latter is
an index into the former (and I don't see it used anywhere).


Have taken out counter now, and, yes, cursor seems happy to execute 
statements without ; character at end.





   print(l_struct[I])
 #except Warning as wrn:
 #  print("warning: " + str(wrn.args))
 except Exception as exc:
   l_struct_errors.append([l_struct[I], copy.copy(exc)])
 finally:
   pass
   cn.commit()


TWO-B: ... here you attempt to force a commit.


That was also during test phase when was just trying to make sure parts of 
this were being executed/committed - taken out additional commits now.





   time.sleep(2.0)
   sNada = raw_input("hit enter to continue with data")
   s_status = "/{0} data".format(str(len(l_data)))
   for I in range(len(l_data)):
 try:
   #self.SetStatusText(str(I) + s_status)
   i_data = I
   if str(l_data[I]).strip() != "": res = 
cur.ex

Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger

See answers below.

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Dennis Lee Bieber" 




The very first hit /I/ get is:
https://social.technet.microsoft.com/Forums/windows/en-US/3932e3eb-c034-4eb7-aa06-4a0a8e6ea493/fault-module-namestackhash0a9e



Played around with data expraction policy changes/settings now, and didn't 
make it change behaviour.







 s_host = str(d_mysql["host"])
 s_user = str(d_mysql["user"])
 s_pass = str(d_mysql["password"])
 s_db = self.s_target_value


ONE: Have you confirmed all of these are coming in correctly

Yes - that mysql.set pickle dump is just a way of storing some string values 
relating to mysql server connection to sort of hide it from an end-user, 
but, yes, the values work fine in that sense.



 cn = MySQLdb.connect(s_host, s_user, s_pass, s_db)
 if cn:
   cn.autocommit = True


TWO-A: you've turned on autocommit here, yet...


Sorry - that was sort of left-over from when was trying to make sure that 
other parts were happening/working - along with trying out specific commit 
call lower down - have tried taking eitehr of them out one by one, to see if 
made a difference, but, no-go.





   cur = cn.cursor()
   i_struct = 0
   i_data = 0
   f = open(self.s_sql_struct_file, "rb")
   s = f.read()
   f.close()
   l_struct = s.split(";")


THREE-A: here you split some string on semicolons, just to...


   f = open(self.s_sql_data_file, "rb")
   s = f.read()
   f.close()
   l_data = unidecode(s).split(";")
   l_struct_errors = []
   l_data_errors = []
   i_start_time = int(time.time())
   s_status = "/{0} structs".format(str(len(l_struct)))
   for I in range(len(l_struct)):


Very UN-Pythonic...


I know - that was also since originally used this code in a sort of GUI 
version, and meant to use one by one counter to update status bar text at 
sort of intervals of 10 records, to let guys track progress - but, FWIW, it 
seemed to overload my screen reader with too many changes, partly since some 
of these collections of insert statements are processing over 4 record 
insertions - not currently with test data, but, some of the other test 
database files I used were operating in that region of the number of data 
record numbers. Have taken that part out again now.




for a_struct in l_struct:
# do stuff with a_struct directly, no indexing into l_struct


 try:
   i_struct = I
   if str(l_struct[I]).strip() != "": res = 
cur.execute(l_struct[I] + ";")


THREE-B: ... reappend the semicolon here... which probably isn't needed
-- cur.execute() assumes, as I recall, that the provided argument is a
complete statement; unlike a command line interface where the semicolon is
needed to tell the CLI that the statement is complete and can be sent to
the DBMS for processing.

And very confusing names... l_struct and i_struct, where the latter is
an index into the former (and I don't see it used anywhere).


Have taken out counter now, and, yes, cursor seems happy to execute 
statements without ; character at end.





   print(l_struct[I])
 #except Warning as wrn:
 #  print("warning: " + str(wrn.args))
 except Exception as exc:
   l_struct_errors.append([l_struct[I], copy.copy(exc)])
 finally:
   pass
   cn.commit()


TWO-B: ... here you attempt to force a commit.


That was also during test phase when was just trying to make sure parts of 
this were being executed/committed - taken out additional commits now.





   time.sleep(2.0)
   sNada = raw_input("hit enter to continue with data")
   s_status = "/{0} data".format(str(len(l_data)))
   for I in range(len(l_data)):
 try:
   #self.SetStatusText(str(I) + s_status)
   i_data = I
   if str(l_data[I]).strip() != "": res = 
cur.execute(l_data[I][l_data[I].index("INSERT"):] + ";")

   print(l_data[I][l_data[I].index("INSERT"):] + ";")
 except Exception as exc:
   l_data_errors.append([l_data[I], copy.copy(exc)])
 finally:
   pass
   i_end_time = int(time.time())
   s_time_taken = sTimeDiffFormat(i_start_time, i_end_time)
   cn.commit()


TWO-C: ... and here too.


   cur.close()
   cn.close()
   print("cn and cur closed")
   fPickle = open("testDataErrors.pickle", "wb")
   pickle.dump(l_struct_errors, fPickle, 2)
   pickle.dump(l_data_errors, fPickle, 2)
   fPickle.close()
   print("pickled")
   print("MySQL Results - {0} structure queries, and {1} data queries 
completed - total of {2}".format(str(i_struct), str(i_data), 
s_time_taken))
   print("MySQL Errors - {0} structure query errors, and {1} data 
query errors".format(str(len(l_struct_errors)), str(len(l_data_errors

   print("Done!")
   sys.exit()
   

Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
Trying to run through all steps in data conversion app, and, up to last point, 
it's fine, but, if I try to handle direct execution of data structure, and data 
insertion scripts against a mySQL database, hosted locally here on same 
machine, running under wamp, then after code has completely finished executing 
everything, the command line just stops, and then I get the windows error 
dialogue pop up, telling me python.exe has stopped working.

If I run the same code on my other dev machine, which might just have a 
slightly simpler/cleaner combination of software, etc. installed on it, then it 
just runs straight through, and exits python interpreter instance, with no 
issues, and am just not sure how to try track down actual cause of this issue.

Here's part of the error dialogue's detailed information:
Problem signature:

Problem Event Name: APPCRASH

Application Name: python.exe

Application Version: 0.0.0.0

Application Timestamp: 4c303241

Fault Module Name: StackHash_0a9e

Fault Module Version: 0.0.0.0

Fault Module Timestamp: 

Exception Code: c005

Exception Offset: 028e1289

OS Version: 6.1.7601.2.1.0.256.1

Locale ID: 2057

Additional Information 1: 0a9e

Additional Information 2: 0a9e372d3b4ad19135b953a78882e789

Additional Information 3: 0a9e

Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

#---end of error info---



If I look for something similar via google, etc., I come across some mention of 
32-64 bit incompatibility, or something, but, not sure if relevant, although am 
working with 32 bit versions of python 2.7, and both of my dev machines are in 
fact 64 bit windows7 machines, but haven't had issues like this in past.



Also, if I exclude last part of code, which handles directly working with MySQL 
database, then all cooperates fine, but, am pretty sure am closing all relevant 
connections, cursors, etc. - here's the last function that am 
calling/executing, in case relevant - there is still some testing/manual 
debugging stuff in here, but anyway:

#---start code---

  def convertExport(self):
try:
  f_mysql = open("mysql.set", "rb")
  d_mysql = pickle.load(f_mysql)
  f_mysql.close()
  cn = None
  s_host = str(d_mysql["host"])
  s_user = str(d_mysql["user"])
  s_pass = str(d_mysql["password"])
  s_db = self.s_target_value
  cn = MySQLdb.connect(s_host, s_user, s_pass, s_db)
  if cn:
cn.autocommit = True
cur = cn.cursor()
i_struct = 0
i_data = 0
f = open(self.s_sql_struct_file, "rb")
s = f.read()
f.close()
l_struct = s.split(";")
f = open(self.s_sql_data_file, "rb")
s = f.read()
f.close()
l_data = unidecode(s).split(";")
l_struct_errors = []
l_data_errors = []
i_start_time = int(time.time())
s_status = "/{0} structs".format(str(len(l_struct)))
for I in range(len(l_struct)):
  try:
i_struct = I
if str(l_struct[I]).strip() != "": res = cur.execute(l_struct[I] + 
";")
print(l_struct[I])
  #except Warning as wrn:
  #  print("warning: " + str(wrn.args))
  except Exception as exc:
l_struct_errors.append([l_struct[I], copy.copy(exc)])
  finally:
pass
cn.commit()
time.sleep(2.0)
sNada = raw_input("hit enter to continue with data")
s_status = "/{0} data".format(str(len(l_data)))
for I in range(len(l_data)):
  try:
#self.SetStatusText(str(I) + s_status)
i_data = I
if str(l_data[I]).strip() != "": res = 
cur.execute(l_data[I][l_data[I].index("INSERT"):] + ";")
print(l_data[I][l_data[I].index("INSERT"):] + ";")
  except Exception as exc:
l_data_errors.append([l_data[I], copy.copy(exc)])
  finally:
pass
i_end_time = int(time.time())
s_time_taken = sTimeDiffFormat(i_start_time, i_end_time)
cn.commit()
cur.close()
cn.close()
print("cn and cur closed")
fPickle = open("testDataErrors.pickle", "wb")
pickle.dump(l_struct_errors, fPickle, 2)
pickle.dump(l_data_errors, fPickle, 2)
fPickle.close()
print("pickled")
print("MySQL Results - {0} structure queries, and {1} data queries 
completed - total of {2}".format(str(i_struct), str(i_data), s_time_taken))
print("MySQL Errors - {0} structure query errors, and {1} data query 
errors".format(str(len(l_struct_errors)), str(len(l_data_errors
print("Done!")
sys.exit()
  else:
print("Connection issue - There was a problem connecting to MySQL 
server")
sys.exit()
except Exception as exc:
  s_exc = str(exc.args)
  #lbc.DialogShow(title="errorMessage", message=s_exc)
  print(s_exc)
  exc_type, exc_obj, tb = sys.exc_info()
  print(str(exc_obj))
  print("line numbe