I will be the first to admit I dont know much about if any about JAVA. Attached is the code I am using on a button.
#from ftplib import FTP
from java.lang import Runnable,Thread
machines = fpmi.db.runQuery(“SELECT mach_num FROM progmode1 WHERE online = 0 and mach_num<10 order by mach_num”)
y = len(machines)
#machines = fpmi.db.runQuery(“SELECT mach_num FROM interim WHERE mach_sel = 1 AND shift = 1”)
#machines = event.source.parent.machine
def __init__(self): self.m= def addMachine(self, machineId): self.m.append(machineId) def run(self): for i in self.m: k=i+10 string = '10.0.0.'+str(k) filename = 'setup.csv' filename2 = 'emp2.csv' try: print "Connecting to %s"%string [b]1. ------>[/b] from ftplib import FTP ftp = FTP(string) print "Connected to %s, Logging in..."%string ftp.login('david','bigbrother') print "Uploading to %s"%string ftp.set_pasv(0) ftp.delete(filename) ftp.delete(filename2) file = open(filename, 'rb') print string,filename ftp.storbinary('STOR '+filename,file) file.close() file2 = open(filename2, 'rb') print string,filename2 ftp.storbinary('STOR '+filename2,file2) file2.close() ftp.quit() print "Done ",i except Exception, e: print "HEY STUPID LOOK HERE IT FAILED. HERE IS WHY: %s. ("%string,e,")" z=z+1
2. ------> fpmi.tag.writeToTag("fault",z)
Create 5 download objects
downloaders = 
for x in range(4):
Round-robin assign machine ids to the downloaders
for row in machines:
m = row
x = (x+1)%len(downloaders)
Start a thread for each of the 5 downloaders
for downloader in downloaders:
What I am trying to do is have a self incrementing counter for each time it successfully connect and one for each time it faults. If you look at #1 above I had the following lines:
But it kept comming up with NAME ERROR: P error message. I did try different letter but all came back with same error message. I get the same type of message but with the letter Z if an error occurs.
In the section CREATE 5 Downloader objects I tried placing:
Here I got a value back but it appears that it only loops thru this routine 3 times.
So where can I place these incremental counters so that they will work properly in this script? Like I said I want the one to count each time there has been success logging into a ftp and one to count each time there has been a failure and then I want to be able to use these on my screen to display.