0

python3.6

I want to make file1 and file2 to work as exec.

tak.py @@main file

from tkinter import *
import subprocess

class App(Frame):

 def __init__(self, okno=None):
     Frame.__init__(self, okno)
     self.okno = okno
     self.init_window()

 def init_window(self):
     self.okno.title("Ping checker")
     self.okno.minsize(width=1000, height=800)
     self.okno.maxsize(width=1000, height=800)
     self.pack(fill=BOTH, expand=1)
     quitbutton = Button(self, text="Exit", height=5, width=25, 
                         command=self.client_exit, fg='black',
                         bg='white', activeforeground='white',             
                          activebackground='black', bd='3')
     startbutton = Button(self, text="Start",height=5, width=25, 
                       command=self.client_start_ping, fg='black',
                       bg='white', activeforeground='white', 
     activebackground='black', bd='3')
     quitbutton.place(x=800, y=700)
     startbutton.place(x=15, y=700)

 def client_exit(self):
     exit()

 def client_start_ping(self):
     var = StringVar()
     label = Message(root, textvariable=var, relief=RAISED)
     label.config(width=666)
     label.place(x=15, y=1)
     try:
         output = subprocess.check_output("fastafping.exe")
     except subprocess.CalledProcessError as e:
         raise RuntimeError("command '{}' return with error (code {}): 
                           {}".format(e.cmd, e.returncode, e.output))
     var.set(output)


root = Tk()
app = App(root)
root.mainloop()

fastafping.py 2nd file

import multiprocessing
import subprocess
import cx_Oracle


def client_start_ping(job_q, results_q, badresults_q):
    y = "ping -c l "
    while True:
        ip = job_q.get()
        if ip is None:
            break

        try:
            subprocess.check_output(str(y) + ip)
            results_q.put(ip)

        except:
            badresults_q.put(ip)


if __name__ == '__main__':
    ipaddress =[]
    jobs = multiprocessing.Queue()
    results = multiprocessing.Queue()
    badresults = multiprocessing.Queue()
    con = cx_Oracle.connect('#####/#####@##.#.#.#/##')
    cur = con.cursor()
    cur.execute("Update IP_CHECK_TAB SET CHECK_ = 'N'")
    cur.execute("Update IP_CHECK_TAB SET CHECK_='Y'")
    cur.execute("Select IP from IP_CHECK_TAB  Order By Ip")
    output = {}
    for a in cur:
        ipaddress.append(a[0])
    pool_size = len(ipaddress)
    pool = [multiprocessing.Process(target=client_start_ping, args=(jobs, 
results, badresults))
         for i in range(pool_size)]
    for p in pool:
        p.start()
    for i in ipaddress:
        jobs.put(i)
    for p in pool:
        jobs.put(None)
    for p in pool:
        p.join()
    while not results.empty():
        ip = results.get()
        print(ip + " : Connected")
        cur.execute("Update IP_CHECK_TAB SET STATUS='ok',STATUS_INFO = 
                    sysdate Where IP = '" + ip + "'")
        output[ip] = "host appears to be up"
    while not badresults.empty():
        ip = badresults.get()
        print(ip + " : Not connected")
        cur.execute("Update IP_CHECK_TAB SET STATUS='nok',STATUS_INFO = 
                    sysdate Where IP = '" + ip + "'")
        output[ip] = "host is not connected"
    con.commit()
    cur.close()
    con.close()

When i am trying to make file tak.py executable with pyinstaller. Output is:

  Traceback (most recent call last):
 File "fastafping.py", line 25, in <module>
cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be 
loaded: "C:\app\Praktyka\product\12.1.0\client_1\oci.dll is not the correct 
architecture". See 
https://oracle.github.io/odpi/doc/installation.html#windows 
for help
[4288] Failed to execute script fastafping
Exception in Tkinter callback
Traceback (most recent call last):
  File "tak.py", line 33, in client_start_ping
  File "subprocess.py", line 336, in check_output
 File "subprocess.py", line 418, in run
subprocess.CalledProcessError: Command 'fastafping.exe' returned non-zero 
 exit 
    status 4294967295.

  During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tkinter\__init__.py", line 1702, in __call__
  File "tak.py", line 35, in client_start_ping
 RuntimeError: command 'fastafping.exe' return with error (code 4294967295): 
b''

I am trying to do everything that i know to do. My applicaton is pinging every ip from oracle database using multiprocessing. All i want is make this in gui and make this work on other pc without installing python

1
  • The error is clear - exit() call from method def client_exit(self) is undefined. Commented Sep 25, 2018 at 8:22

1 Answer 1

1

The error is clear - exit() call from method def client_exit(self) is undefined. You can try to use sys.exit() (and add import sys). Or look for other solution here.

Sign up to request clarification or add additional context in comments.

10 Comments

Maybe but it isn't about exit, I cant start program becouse of not working client_start_ping
@Tigerly Why you think so? From error message from your post File "tak.py", line 25, in client_exit.
This is error when i am trying to exit from interface, i showed you all errors that occurs. My program is working perfectly without making him exe
@Tigerly You wrote 'When i am trying to make file tak.py executable with pyinstaller'. pyinstaller raise 'NameError' on unknown name exit(). When you just run your script with python you doesn't see this error, because interpreter will visit client_exit only on exit.
@Tigerly And now you can pack your code as execution file and run on other machine?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.