Note that there are some explanatory texts on larger screens.

plurals
  1. POScript calling multiple other scripts erroring due to undefined functions
    primarykey
    data
    text
    <p>I'm unsure again with something what I'm sure is going to be very simple...</p> <p>Basically, I'm trying to make my first script call/execute a bunch of other scripts but the problem is I want each individual script to contain its own functions not be called from the first secript...</p> <p>First script/main script:</p> <pre><code>from datetime import date, timedelta from sched import scheduler from time import time, sleep, strftime import random s = scheduler(time, sleep) random.seed() def periodically(runtime, intsmall, intlarge, function): ## Get current time currenttime = strftime('%H:%M:%S') ## If currenttime is anywhere between 23:40 and 23:50 then... if currenttime &gt; '23:40:00' and currenttime &lt; '23:50:00': ## Call clear clear() ## Update time currenttime = strftime('%H:%M:%S') ## Idle time while currenttime &gt; '23:40:00' and currenttime &lt; '23:59:59' or currenttime &gt;= '00:00:00' and currenttime &lt; '01:30:00': ## Update time currenttime = strftime('%H:%M:%S') runtime += random.randrange(intsmall, intlarge) s.enter(runtime, 1, function, ()) s.run() def callscripts(): print "Calling Functions" errors = open('ERROR(S).txt', 'a') try: execfile("data/secondary.py") except Exception as e: errors.write(str(e)) errors.write(""" """) errors.close() while True: periodically(2, -1, +1, callscripts) </code></pre> <p>Below is secondary.py</p> <pre><code>import win32con from win32api import * from win32gui import * class WindowsBalloonTip: def __init__(self, title, msg): message_map = { win32con.WM_DESTROY: self.OnDestroy,} # Register the window class. wc = WNDCLASS() hinst = wc.hInstance = GetModuleHandle(None) wc.lpszClassName = 'PythonTaskbar' wc.lpfnWndProc = message_map # could also specify a wndproc. classAtom = RegisterClass(wc) # Create the window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = CreateWindow(classAtom, "Taskbar", style, 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, hinst, None) UpdateWindow(self.hwnd) # Icons managment iconPathName = "icon1.ico" ## LOCATION TO THE ICON FILE icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE try: hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags) except: hicon = LoadIcon(0, win32con.IDI_APPLICATION) flags = NIF_ICON | NIF_MESSAGE | NIF_TIP nid = (self.hwnd, 0, flags, win32con.WM_USER+20, hicon, 'Tooltip') # Notify Shell_NotifyIcon(NIM_ADD, nid) Shell_NotifyIcon(NIM_MODIFY, (self.hwnd, 0, NIF_INFO, win32con.WM_USER+20, hicon, 'Balloon Tooltip', msg, 200, title)) # self.show_balloon(title, msg) sleep(5) # Destroy DestroyWindow(self.hwnd) classAtom = UnregisterClass(classAtom, hinst) def OnDestroy(self, hwnd, msg, wparam, lparam): nid = (self.hwnd, 0) Shell_NotifyIcon(NIM_DELETE, nid) PostQuitMessage(0) # Terminate the app. # Function def balloon_tip(title, msg): w=WindowsBalloonTip(title, msg) balloon_tip("test test", "Running") def hi(): print "hi" hi() </code></pre> <p>Error:</p> <pre><code>global name 'WindowsBalloonTip' is not defined </code></pre> <p>Full Error:</p> <pre><code>Traceback (most recent call last): File "C:\Main.py", line 48, in &lt;module&gt; periodically(2, -1, +1, callscripts) File "C:\Main.py", line 27, in periodically s.run() File "C:\Python27\lib\sched.py", line 117, in run action(*argument) File "Main.py", line 34, in callscripts execfile("data/secondary.py") File "data/secondary.py", line 93, in &lt;module&gt; balloon_tip("test test", "Running") File "data/secondary.py", line 78, in balloon_tip w=WindowsBalloonTip(title, msg) NameError: global name 'WindowsBalloonTip' is not defined </code></pre> <p>How would I go about fixing this?</p> <p>Thanks in advance Hyflex</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload