So I am trying to make a small GUI in python (version 3.8.3) using tkinter. I wrote the whole script in the PyCharm IDE and I was able to run it without issue and still can. However trying to run it from the command line results in a crash and I get the following output:
2020-07-25 22:22:57.888 Python[69416:1640503] -[SDLApplication
_setup:]: unrecognized selector sent to instance 0x7ffcdd2ad590 2020-07-25 22:22:57.890 Python[69416:1640503] *** Terminating app due
to uncaught exception 'NSInvalidArgumentException', reason:
'-[SDLApplication _setup:]: unrecognized selector sent to instance
0x7ffcdd2ad590'
*** First throw call stack: ( 0 CoreFoundation 0x00007fff378a7797 __exceptionPreprocess + 250 1 libobjc.A.dylib
0x00007fff7073aa9e objc_exception_throw + 48 2 CoreFoundation
0x00007fff379269a6 -[NSObject(NSObject) __retain_OA] + 0 3
CoreFoundation 0x00007fff3780bf30
forwarding + 1427 4 CoreFoundation 0x00007fff3780b908 _CF_forwarding_prep_0 + 120 5 libtk8.6.dylib
0x000000010fd051f2 TkpInit + 408 6 libtk8.6.dylib
0x000000010fc74aac Initialize + 2454 7
_tkinter.cpython-38-darwin.so 0x000000010fac8714 Tcl_AppInit + 84 8 _tkinter.cpython-38-darwin.so 0x000000010fac8032
_tkinter_create + 1362 9 Python 0x000000010f790e8f cfunction_vectorcall_FASTCALL + 175 10 Python
0x000000010f822c4c call_function + 444 11 Python
0x000000010f81faae _PyEval_EvalFrameDefault + 25678 12 Python
0x000000010f823a94 _PyEval_EvalCodeWithName + 2804 13 Python
0x000000010f75504e _PyFunction_Vectorcall + 270 14 Python
0x000000010f7543b7 _PyObject_FastCallDict + 247 15 Python
0x000000010f7559bf _PyObject_Call_Prepend + 143 16 Python
0x000000010f7abb21 slot_tp_init + 145 17 Python
0x000000010f7a6ff9 type_call + 297 18 Python
0x000000010f754565 _PyObject_MakeTpCall + 373 19 Python
0x000000010f822ca5 call_function + 533 20 Python
0x000000010f81faae _PyEval_EvalFrameDefault + 25678 21 Python
0x000000010f823a94 _PyEval_EvalCodeWithName + 2804 22 Python
0x000000010f819584 PyEval_EvalCode + 100 23 Python
0x000000010f8690f0 PyRun_FileExFlags + 336 24 Python
0x000000010f8687e0 PyRun_SimpleFileExFlags + 864 25 Python
0x000000010f885c6f Py_RunMain + 2159 26 Python
0x000000010f885faf pymain_main + 223 27 Python
0x000000010f8861ab Py_BytesMain + 43 28 libdyld.dylib
0x00007fff718d9cc9 start + 1 29 ???
0x0000000000000002 0x0 + 2 ) libc++abi.dylib: terminating with
uncaught exception of type NSException Abort trap: 6
The script ran perfectly when being called from the command line on a Windows computer but for whatever reason I cant get it to run from the command line on my mac, but yet it works in the IDE...
I'll include the code below. I would appreciate any help I can get and if you need more information just ask
import tkinter as tk
import youtube_dl
from moviepy.editor import *
import shutil
BG = "#191970"
# midnight blue #191970
main_window = tk.Tk()
main_window.title("Video Scraper")
main_window.geometry("850x690")
main_window.config(bg=BG)
frame = tk.Frame(main_window, bg="white")
frame.place(relx="0.1", rely="0.05", relwidth=0.8, relheight=0.9)
title = tk.Label(frame, text="Video Scraper")
title.config(font=("Verdana", 44))
title.pack(fill="x")
label = tk.Label(frame, text="Please enter the url(s) of the videos you would like to download so that there's "
"only 1 link per line\nAlso note that there can't be any spaces at the beginning or "
"end of the line", bg="pink")
label.pack()
text_area = tk.Text(frame, bg="#BBFFFF")
text_area.pack(fill="y", expand=True)
frame2 = tk.Frame(main_window, bg=BG)
frame2.place(relx="0.2", rely="0.95", relwidth=0.6, relheight=0.05)
var = tk.IntVar()
var.set(2)
def set_var1():
var.set(1)
def set_var2():
var.set(2)
audio_only = tk.Radiobutton(frame2, text=".mp3", variable="var", value=1, command=set_var1)
vid_and_aud = tk.Radiobutton(frame2, text=".mp4", variable="var", value=2, command=set_var2)
audio_only.pack(side="left")
vid_and_aud.pack(side="left")
def get_text():
text = text_area.get("1.0", "end-1c")
broken_text = text.split("\n")
links = []
for item in broken_text:
link = [item]
links.append(link)
audio_only.config(state="disabled")
vid_and_aud.config(state="disabled")
download_btn.config(state="disabled")
download_videos(links, var.get())
def download_videos(url_links, download_format):
counter = 0
vid_info = []
print(url_links)
print(download_format)
# Get video data for each link and put it into a list
with youtube_dl.YoutubeDL() as ydl:
for link in url_links:
meta = ydl.extract_info(link[0], download=False)
vid_info.append(meta)
ydl_opts = {
'format': 'mp4',
'outtmpl': '%(title)s.mp4',
'quiet': True,
'noplaylist': True
}
while counter < len(url_links):
filename = vid_info[counter]['title'] + ".mp4"
print("\n\nDownloading --> " + filename)
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(url_links[counter])
print("Video Successfully Downloaded!")
if download_format == 1:
print("Converting Video(.mp4) to Audio(.mp3)...")
video = VideoFileClip(filename)
audio_file = filename.replace("mp4", "mp3")
video.audio.write_audiofile(audio_file, logger=None)
video.close()
print("Video Successfully Converted!")
print("Cleaning up...")
# remove video file
print("--> Removing Video(.mp4) File")
os.remove(filename)
# move audio
print("--> Moving Audio to Audio(mp3) Folder")
shutil.move(audio_file, "Audio(mp3)")
print("--> Done")
print("Completed " + str(counter + 1) + "/" + str(len(url_links)))
else:
shutil.move(filename, "Video(mp4)")
print("Completed " + str(counter + 1) + "/" + str(len(url_links)))
counter += 1
download_btn = tk.Button(frame2, text="Download!", command=get_text)
download_btn.pack(side="right")
main_window.mainloop()
Related
I was trying to zip up an application bundle using shutil.make_archive using zip format, like this
app_pkg = '/path/to/my.app'
shutil.make_archive(app_pkg, 'zip', '/path/to/installer')
The produced zip file extracts to /path/to/installer without issues.
But the app inside the installer folder, i.e., /path/to/installer/my.app, crashes when double-clicked.
The full crash log looks like this
Process: mia [32751]
Path: /Users/USER/Desktop/*/mia.app/Contents/MacOS/mia
Identifier: com.example.mia
Version: 1.0.0 (1)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: mia [32751]
User ID: 527235363
Date/Time: 2021-06-06 20:20:49.763 +0800
OS Version: macOS 11.3.1 (20E241)
Report Version: 12
Bridge OS Version: 5.3 (18P4556)
Anonymous UUID: 3D0E276C-DA9D-1DF6-7059-6A3AACF3A73D
Time Awake Since Boot: 1000000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff208c798b __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff205ffd92 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2097d32a _CFThrowFormattedException + 202
3 CoreFoundation 0x00007fff2097b581 -[__NSPlaceholderArray initWithCapacity:].cold.1 + 0
4 CoreFoundation 0x00007fff207d0230 -[__NSPlaceholderArray initWithObjects:count:] + 154
5 CoreFoundation 0x00007fff2082a793 +[NSArray arrayWithObjects:count:] + 40
6 FlutterMacOS 0x00000001055b1b14 -[FlutterEngine loadAOTData:] + 148
7 FlutterMacOS 0x00000001055b1766 -[FlutterEngine runWithEntrypoint:] + 1526
8 FlutterMacOS 0x00000001055be487 -[FlutterViewController launchEngine] + 87
9 FlutterMacOS 0x00000001055be0c5 -[FlutterViewController viewWillAppear] + 101
10 AppKit 0x00007fff23194320 -[NSViewController _sendViewWillAppear] + 40
11 AppKit 0x00007fff231941e0 -[NSViewController _windowWillOrderOnScreen] + 98
12 AppKit 0x00007fff238e91fe -[NSView _windowWillOrderOnScreen] + 67
13 AppKit 0x00007fff238e9294 -[NSView _windowWillOrderOnScreen] + 217
14 AppKit 0x00007fff23194071 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 59
15 AppKit 0x00007fff2319201f -[NSWindow _reallyDoOrderWindowAboveOrBelow:relativeTo:findKey:forCounter:force:isModal:] + 1319
16 AppKit 0x00007fff231917a0 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 135
17 AppKit 0x00007fff23190797 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 289
18 AppKit 0x00007fff23190614 -[NSWindow orderWindow:relativeTo:] + 155
19 AppKit 0x00007fff2302675f -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 2033
20 AppKit 0x00007fff2301abb8 loadNib + 392
21 AppKit 0x00007fff2301a1c4 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 693
22 AppKit 0x00007fff23019e1a -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 201
23 AppKit 0x00007fff23019bf8 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 394
24 AppKit 0x00007fff2300c762 NSApplicationMain + 566
25 mia 0x000000010559b759 main + 9
26 libdyld.dylib 0x00007fff2076ff3d start + 1
27 ??? 0x0000000000000001 0x0 + 1
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff20725946 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff20754615 pthread_kill + 263
2 libsystem_c.dylib 0x00007fff206a9411 abort + 120
3 libc++abi.dylib 0x00007fff20717ef2 abort_message + 241
4 libc++abi.dylib 0x00007fff207095fd demangling_terminate_handler() + 266
5 libobjc.A.dylib 0x00007fff2060258d _objc_terminate() + 96
6 libc++abi.dylib 0x00007fff20717307 std::__terminate(void (*)()) + 8
7 libc++abi.dylib 0x00007fff20719beb __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
8 libc++abi.dylib 0x00007fff20719bb2 __cxa_throw + 116
9 libobjc.A.dylib 0x00007fff205ffec0 objc_exception_throw + 350
10 com.apple.CoreFoundation 0x00007fff2097d32a _CFThrowFormattedException + 202
11 com.apple.CoreFoundation 0x00007fff2097b581 -[__NSPlaceholderArray initWithObjects:count:].cold.3 + 38
12 com.apple.CoreFoundation 0x00007fff207d0230 -[__NSPlaceholderArray initWithObjects:count:] + 154
13 com.apple.CoreFoundation 0x00007fff2082a793 +[NSArray arrayWithObjects:count:] + 40
14 io.flutter.flutter-macos 0x00000001055b1b14 -[FlutterEngine loadAOTData:] + 148
15 io.flutter.flutter-macos 0x00000001055b1766 -[FlutterEngine runWithEntrypoint:] + 1526
16 io.flutter.flutter-macos 0x00000001055be487 -[FlutterViewController launchEngine] + 87
17 io.flutter.flutter-macos 0x00000001055be0c5 -[FlutterViewController viewWillAppear] + 101
18 com.apple.AppKit 0x00007fff23194320 -[NSViewController _sendViewWillAppear] + 40
19 com.apple.AppKit 0x00007fff231941e0 -[NSViewController _windowWillOrderOnScreen] + 98
20 com.apple.AppKit 0x00007fff238e91fe -[NSView _windowWillOrderOnScreen] + 67
21 com.apple.AppKit 0x00007fff238e9294 -[NSView _windowWillOrderOnScreen] + 217
22 com.apple.AppKit 0x00007fff23194071 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 59
23 com.apple.AppKit 0x00007fff2319201f -[NSWindow _reallyDoOrderWindowAboveOrBelow:relativeTo:findKey:forCounter:force:isModal:] + 1319
24 com.apple.AppKit 0x00007fff231917a0 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 135
25 com.apple.AppKit 0x00007fff23190797 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 289
26 com.apple.AppKit 0x00007fff23190614 -[NSWindow orderWindow:relativeTo:] + 155
27 com.apple.AppKit 0x00007fff2302675f -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 2033
28 com.apple.AppKit 0x00007fff2301abb8 loadNib + 392
29 com.apple.AppKit 0x00007fff2301a1c4 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 693
30 com.apple.AppKit 0x00007fff23019e1a -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 201
31 com.apple.AppKit 0x00007fff23019bf8 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 394
32 com.apple.AppKit 0x00007fff2300c762 NSApplicationMain + 566
33 com.example.mia 0x000000010559b759 main + 9 (AppDelegate.swift:5)
34 libdyld.dylib 0x00007fff2076ff3d start + 1
Thread 1:
0 libsystem_pthread.dylib 0x00007fff20750484 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x00007fff20750484 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00007fff20750484 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x00007fff20750484 start_wqthread + 0
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x000000010c7eae00 rcx: 0x00007ffeea664318 rdx: 0x0000000000000000
rdi: 0x0000000000000103 rsi: 0x0000000000000006 rbp: 0x00007ffeea664340 rsp: 0x00007ffeea664318
r8: 0x00007ffeea6641e0 r9: 0x0000000000000000 r10: 0x000000010c7eae00 r11: 0x0000000000000246
r12: 0x0000000000000103 r13: 0x0000003000000008 r14: 0x0000000000000006 r15: 0x0000000000000016
rip: 0x00007fff20725946 rfl: 0x0000000000000246 cr2: 0x00007fff87442fd0
Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133
Thread 0 instruction stream not available.
Thread 0 last branch register state not available.
Binary Images:
0x105599000 - 0x10559cfff +com.example.mia (1.0.0 - 1) <6FDB6C75-DD8C-3E3A-AC4E-B7DE513EB0F5> /Users/USER/Desktop/*/mia.app/Contents/MacOS/mia
0x1055ad000 - 0x106014fff +io.flutter.flutter-macos (1.0 - 1.0) <E04597C4-4CD7-3C8C-9387-DE1D1C021257> /Users/USER/Desktop/*/mia.app/Contents/Frameworks/FlutterMacOS.framework/Versions/A/FlutterMacOS
0x1099c1000 - 0x1099d0fff libobjc-trampolines.dylib (824) <443A76FC-45AB-380A-98BF-EF0466708A33> /usr/lib/libobjc-trampolines.dylib
0x10a810000 - 0x10ab23fff +App (0) <7CF9C6C2-B0CB-33AD-B315-07BAFEA054D7> /Users/USER/Desktop/*/mia.app/Contents/Frameworks/App.framework/App
0x10c713000 - 0x10c7aefff dyld (851.27) <7EAA668B-F906-3BAA-A980-139BBE6E8766> /usr/lib/dyld
0x7fff2048c000 - 0x7fff2048dfff libsystem_blocks.dylib (79) <1C8538C3-F2BE-3F02-89AE-E7052DE66D51> /usr/lib/system/libsystem_blocks.dylib
0x7fff2048e000 - 0x7fff204c3fff libxpc.dylib (2038.100.48) <CFB56DA8-7462-3E8F-9CFB-20926C6A2BB5> /usr/lib/system/libxpc.dylib
0x7fff204c4000 - 0x7fff204dbfff libsystem_trace.dylib (1277.100.21) <1AAE1F8F-9F9D-3327-8A95-3A6887CED713> /usr/lib/system/libsystem_trace.dylib
0x7fff204dc000 - 0x7fff20579fff libcorecrypto.dylib (1000.100.38) <96A88875-7771-394E-A88E-389DCD02A935> /usr/lib/system/libcorecrypto.dylib
0x7fff2057a000 - 0x7fff205a6fff libsystem_malloc.dylib (317.100.9) <029B5632-62B4-39F6-981C-BCA99C1FBF1D> /usr/lib/system/libsystem_malloc.dylib
0x7fff205a7000 - 0x7fff205ebfff libdispatch.dylib (1271.100.5) <6B7B23E3-2FD4-3EA2-8A89-CE06244CCA98> /usr/lib/system/libdispatch.dylib
0x7fff205ec000 - 0x7fff20625fff libobjc.A.dylib (824) <929E3040-4605-3C14-885B-D742EF02F2CB> /usr/lib/libobjc.A.dylib
0x7fff20626000 - 0x7fff20628fff libsystem_featureflags.dylib (28.60.1) <FEA91919-A5BB-3606-9445-F2077D90BF87> /usr/lib/system/libsystem_featureflags.dylib
0x7fff20629000 - 0x7fff206b1fff libsystem_c.dylib (1439.100.3) <DF45CDEC-6B7E-3586-94B4-F3679A762661> /usr/lib/system/libsystem_c.dylib
0x7fff206b2000 - 0x7fff20707fff libc++.1.dylib (905.6) <B027735F-B398-381C-84A7-606D7BBE4997> /usr/lib/libc++.1.dylib
0x7fff20708000 - 0x7fff2071dfff libc++abi.dylib (905.6) <22AFC7FC-2DB6-3EF0-9CC0-EFFB9B65D5E2> /usr/lib/libc++abi.dylib
0x7fff2071e000 - 0x7fff2074dfff libsystem_kernel.dylib (7195.101.2) <62A19DE4-50C5-3866-B5B2-43220E379C3B> /usr/lib/system/libsystem_kernel.dylib
0x7fff2074e000 - 0x7fff20759fff libsystem_pthread.dylib (454.100.8) <52F807B1-41A0-3D1E-AE89-115CA570863F> /usr/lib/system/libsystem_pthread.dylib
0x7fff2075a000 - 0x7fff20795fff libdyld.dylib (851.27) <9F95C644-D1BD-38D9-9612-6188FE9EA53C> /usr/lib/system/libdyld.dylib
0x7fff20796000 - 0x7fff2079ffff libsystem_platform.dylib (254.80.2) <03429519-EBEA-3549-84A6-0FD426CB7373> /usr/lib/system/libsystem_platform.dylib
0x7fff207a0000 - 0x7fff207cbfff libsystem_info.dylib (542.40.3) <C189F0D7-A430-328D-BD7F-7EB0FA023736> /usr/lib/system/libsystem_info.dylib
0x7fff207cc000 - 0x7fff20c69fff com.apple.CoreFoundation (6.9 - 1775.118.101) <895AFD1C-0307-32B3-81CB-BA33DA368DE1> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff20c6a000 - 0x7fff20e9cfff com.apple.LaunchServices (1122.33 - 1122.33) <CBFF2714-646C-3DDB-906D-672E420683E6> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x7fff20e9d000 - 0x7fff20f70fff com.apple.gpusw.MetalTools (1.0 - 1) <CD0A257C-70F9-3C42-A13E-76FD54BEFD96> /System/Library/PrivateFrameworks/MetalTools.framework/Versions/A/MetalTools
0x7fff20f71000 - 0x7fff211cdfff libBLAS.dylib (1336.101.1) <28ABAD61-A323-33C6-8674-8A14118D4C20> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x7fff211ce000 - 0x7fff2121afff com.apple.Lexicon-framework (1.0 - 86.1) <27959773-C4F4-33BC-9A68-39EF2037F1E5> /System/Library/PrivateFrameworks/Lexicon.framework/Versions/A/Lexicon
0x7fff2121b000 - 0x7fff21289fff libSparse.dylib (106) <A666D9B0-8979-3C9C-83D6-1C0B535B8B0F> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparse.dylib
0x7fff2128a000 - 0x7fff21307fff com.apple.SystemConfiguration (1.20 - 1.20) <BEDC3BFB-D680-3E56-9A3A-2FAB181C52A9> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x7fff21308000 - 0x7fff2133cfff libCRFSuite.dylib (50) <E49A8F87-3F3A-3A0F-853E-65FA6FB33E77> /usr/lib/libCRFSuite.dylib
0x7fff2133d000 - 0x7fff21575fff libmecabra.dylib (929.9) <87ACCBB5-FD09-3044-B6FF-1A94A7129DDF> /usr/lib/libmecabra.dylib
0x7fff21576000 - 0x7fff218d3fff com.apple.Foundation (6.9 - 1775.118.101) <5B112EDB-35C1-31A7-BFDA-E185D1B49D93> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x7fff218d4000 - 0x7fff219bcfff com.apple.LanguageModeling (1.0 - 247.3) <81DEF845-C1A0-3BD0-9820-D1C308AFBE09> /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling
0x7fff219bd000 - 0x7fff21af3fff com.apple.CoreDisplay (236.4 - 236.4) <C1F98CC6-5C02-372D-BFC8-420DEF159C9D> /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
0x7fff21af4000 - 0x7fff21d64fff com.apple.audio.AudioToolboxCore (1.0 - 1180.90) <EB4DE2B5-7947-3422-8151-9E1BDA2B3183> /System/Library/PrivateFrameworks/AudioToolboxCore.framework/Versions/A/AudioToolboxCore
0x7fff21d65000 - 0x7fff21f49fff com.apple.CoreText (677.4.0.4 - 677.4.0.4) <F65330BD-9D48-3DE5-9E6B-1232B5BDB656> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
0x7fff21f4a000 - 0x7fff225dafff com.apple.audio.CoreAudio (5.0 - 5.0) <68667A4E-B4BC-3DF4-9D34-1E3ECECF7E0F> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x7fff225db000 - 0x7fff2292ffff com.apple.security (7.0 - 59754.100.106) <E9261CB0-E729-3F58-98B7-172F243D4427> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x7fff22930000 - 0x7fff22b8ffff libicucore.A.dylib (66112) <478D57C3-FFF8-35E1-A64F-8490A616AB37> /usr/lib/libicucore.A.dylib
0x7fff22b90000 - 0x7fff22b99fff libsystem_darwin.dylib (1439.100.3) <28AB0CBC-61F6-3A01-BCE2-A53DA1AECB0F> /usr/lib/system/libsystem_darwin.dylib
0x7fff22b9a000 - 0x7fff22e85fff com.apple.CoreServices.CarbonCore (1307.2 - 1307.2) <C43BE82A-9E75-39C3-807F-2E87B97B7A78> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x7fff22e86000 - 0x7fff22ec4fff com.apple.CoreServicesInternal (476.1 - 476.1) <65BD8E8C-2F23-3790-B9CB-C04671BE34EE> /System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal
0x7fff22ec5000 - 0x7fff22efffff com.apple.CSStore (1122.33 - 1122.33) <209D2E9A-FC95-3E51-A0DC-4F32C21B2266> /System/Library/PrivateFrameworks/CoreServicesStore.framework/Versions/A/CoreServicesStore
0x7fff22f00000 - 0x7fff22faefff com.apple.framework.IOKit (2.0.2 - 1845.100.19) <99034CC2-EC1B-38C0-A8DE-CE37672DF139> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x7fff22faf000 - 0x7fff22fbafff libsystem_notify.dylib (279.40.4) <1AA89769-E07F-37CD-BBCF-6DBD345862EB> /usr/lib/system/libsystem_notify.dylib
0x7fff22fbb000 - 0x7fff23008fff libsandbox.1.dylib (1441.101.1) <EC86BFE6-4909-356F-BBEF-DDB1C886D38E> /usr/lib/libsandbox.1.dylib
0x7fff23009000 - 0x7fff23d50fff com.apple.AppKit (6.9 - 2022.44.151) <10AFBC3A-E9A4-3E62-B9F5-97DF579B7A84> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x7fff23d51000 - 0x7fff23f9ffff com.apple.UIFoundation (1.0 - 728.6) <C815FD3F-C0F0-31F6-B60D-C544D807384F> /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation
0x7fff23fa0000 - 0x7fff23fb2fff com.apple.UniformTypeIdentifiers (636.9 - 636.9) <5F110054-A401-34EA-B789-F62B6B152DC4> /System/Library/Frameworks/UniformTypeIdentifiers.framework/Versions/A/UniformTypeIdentifiers
0x7fff23fb3000 - 0x7fff2413dfff com.apple.desktopservices (1.19 - 1346.4.7) <A3CAC396-18DC-3B13-9505-54BE001014CE> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x7fff2441d000 - 0x7fff24a9cfff libnetwork.dylib (2288.100.111) <8D567D13-AE70-34BF-834D-9A65C702A8EA> /usr/lib/libnetwork.dylib
0x7fff24a9d000 - 0x7fff24f3bfff com.apple.CFNetwork (1237 - 1237) <347078F9-34AC-3AD5-AA02-B7E5E1D11FB6> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x7fff24f3c000 - 0x7fff24f4afff libsystem_networkextension.dylib (1295.101.1) <33F45B5A-D346-3E7F-AB34-DFC4387E5A3C> /usr/lib/system/libsystem_networkextension.dylib
0x7fff24f4b000 - 0x7fff24f4bfff libenergytrace.dylib (22.100.1) <C6283CA4-26A1-352B-B678-C81D0E5E02D6> /usr/lib/libenergytrace.dylib
0x7fff24f4c000 - 0x7fff24fa8fff libMobileGestalt.dylib (978.100.37) <1B957D3E-C0F7-36AF-98E4-8897F8633BEA> /usr/lib/libMobileGestalt.dylib
0x7fff24fa9000 - 0x7fff24fbffff libsystem_asl.dylib (385) <4D4E0D4F-8B40-3ACC-85E1-16375966D6CC> /usr/lib/system/libsystem_asl.dylib
0x7fff24fc0000 - 0x7fff24fd7fff com.apple.TCC (1.0 - 1) <10E022E6-5939-32DF-80E7-11BEA294F987> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x7fff24fd8000 - 0x7fff2533bfff com.apple.SkyLight (1.600.0 - 585) <5DB42D5D-CF51-3433-96E6-B2987E0C33C8> /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight
0x7fff2533c000 - 0x7fff259c5fff com.apple.CoreGraphics (2.0 - 1463.14.2) <E16063AD-03D6-3DC7-A1D4-7103D3721A5A> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x7fff259c6000 - 0x7fff25abcfff com.apple.ColorSync (4.13.0 - 3473.4.3) <69831124-C7EE-3E6E-AC2E-6DCF8A96DB02> /System/Library/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x7fff25abd000 - 0x7fff25b18fff com.apple.HIServices (1.22 - 715) <7F4A58B2-2A3A-321D-BD82-536D0E37A759> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x7fff25ebf000 - 0x7fff262defff com.apple.CoreData (120 - 1048) <E44CC602-AE8E-3AC0-A3D4-37E9A5AA949F> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x7fff262df000 - 0x7fff262f4fff com.apple.ProtocolBuffer (1 - 285.24.10.20.1) <B83422A6-FA4A-3E24-891F-15851A8D8265> /System/Library/PrivateFrameworks/ProtocolBuffer.framework/Versions/A/ProtocolBuffer
0x7fff262f5000 - 0x7fff264a8fff libsqlite3.dylib (321.3) <39129A81-0E78-3130-85AD-5FA0BFBCC6FA> /usr/lib/libsqlite3.dylib
0x7fff264a9000 - 0x7fff26525fff com.apple.Accounts (113 - 113) <928FC136-F5E1-3865-8384-AB5B7A626C7C> /System/Library/Frameworks/Accounts.framework/Versions/A/Accounts
0x7fff26526000 - 0x7fff2653dfff com.apple.commonutilities (8.0 - 900) <951F55FB-F13F-30E6-AB97-1CEEBE0E78DE> /System/Library/PrivateFrameworks/CommonUtilities.framework/Versions/A/CommonUtilities
0x7fff2653e000 - 0x7fff265bdfff com.apple.BaseBoard (526 - 526) <E88C7B2A-5372-3E8C-B719-AAC35B0F4E91> /System/Library/PrivateFrameworks/BaseBoard.framework/Versions/A/BaseBoard
0x7fff265be000 - 0x7fff26606fff com.apple.RunningBoardServices (1.0 - 505.100.7.0.1) <2E2672F5-C9F1-36E4-B3BA-D3561D7D8BEC> /System/Library/PrivateFrameworks/RunningBoardServices.framework/Versions/A/RunningBoardServices
0x7fff26607000 - 0x7fff2667bfff com.apple.AE (918.4 - 918.4) <5377134F-CCA8-3610-8888-8598115A8E8F> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x7fff2667c000 - 0x7fff26682fff libdns_services.dylib (1310.100.10) <CCC9994C-9A07-3740-98AE-908617A67CA5> /usr/lib/libdns_services.dylib
0x7fff26683000 - 0x7fff2668afff libsystem_symptoms.dylib (1431.100.22) <226C631F-5380-395A-AA20-D686AEA05B9B> /usr/lib/system/libsystem_symptoms.dylib
0x7fff2668b000 - 0x7fff2680ffff com.apple.Network (1.0 - 1) <E70D5387-9843-34AB-B8C4-F468EB7EB1EF> /System/Library/Frameworks/Network.framework/Versions/A/Network
0x7fff26810000 - 0x7fff2683ffff com.apple.analyticsd (1.0 - 1) <356D0732-7AC4-3579-A96E-640FD4C9AB56> /System/Library/PrivateFrameworks/CoreAnalytics.framework/Versions/A/CoreAnalytics
0x7fff26840000 - 0x7fff26842fff
If I zip up the /path/to/installer folder using macOS's own zip utility, the app works fine.
I made a binary comparison between both results and couldn't find obvious differences, except for the .DS_Store file. But I never had issues with .DS_Store before in this sort of scenarios, so I don't believe that's the cause.
Where am I wrong?
Found the issue. shutil.make_archive() does not follow symlinks as of python 3.9.5. So the symlinks are not included in the zips.
This corrupts the lib and executable bundles such as *.framework's.
A workaround I round is to use gztar instead of zip, which preserves the essential symlinks.
shutil.make_archive(app_pkg, 'gztar', '/path/to/installer')
Can I render an openCV animation from a background thread in Python?
Here is my attempt:
import cv2
import numpy as np
from time import sleep
bitmap = np.zeros((512,512,3),np.uint8)
import threading
import time
def update_bitmap():
for i in range(512):
bitmap[i,i,:] = 128
sleep(1/32)
threading.Thread(target=update_bitmap).start()
def refresh_gui():
hz = 30
delta_t = 1 / hz
t = time.time()
while True:
sleep(0.001)
if time.time() > t+delta_t:
t += delta_t
cv2.imshow("Color Image", bitmap)
cv2.waitKey(1)
threading.Thread(target=refresh_gui).start()
try:
while True:
print('tick')
sleep(1)
except KeyboardInterrupt:
cv2.destroyAllWindows()
exit(0)
However it fails with:
> python test.py
tick
2021-03-14 17:01:37.474 python[38483:2301820] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
0 AppKit 0x00007fff22c7347f -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 352
1 AppKit 0x00007fff22c5e121 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1375
2 AppKit 0x00007fff22c5dbbb -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
3 AppKit 0x00007fff22f681f4 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
4 cv2.cpython-37m-darwin.so 0x00000001084cc4f5 cvNamedWindow + 677
5 cv2.cpython-37m-darwin.so 0x00000001084cbdbc cvShowImage + 188
6 cv2.cpython-37m-darwin.so 0x00000001084ca286 _ZN2cv6imshowERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS_11_InputArrayE + 230
7 cv2.cpython-37m-darwin.so 0x000000010749515e _ZL18pyopencv_cv_imshowP7_objectS0_S0_ + 302
8 python 0x0000000106fcd4e8 _PyMethodDef_RawFastCallKeywords + 392
9 python 0x0000000107109ce2 call_function + 306
10 python 0x0000000107106a83 _PyEval_EvalFrameDefault + 42243
11 python 0x0000000106fccbe5 function_code_fastcall + 117
12 python 0x0000000107107bf2 _PyEval_EvalFrameDefault + 46706
13 python 0x0000000106fccbe5 function_code_fastcall + 117
14 python 0x0000000107109c67 call_function + 183
15 python 0x00000001071069ed _PyEval_EvalFrameDefault + 42093
16 python 0x0000000106fccbe5 function_code_fastcall + 117
17 python 0x0000000107109c67 call_function + 183
18 python 0x00000001071069ed _PyEval_EvalFrameDefault + 42093
19 python 0x0000000106fccbe5 function_code_fastcall + 117
20 python 0x0000000106fd0002 method_call + 130
21 python 0x0000000106fcda82 PyObject_Call + 130
22 python 0x00000001071eb89b t_bootstrap + 123
23 python 0x0000000107172937 pythread_wrapper + 39
24 libsystem_pthread.dylib 0x00007fff20332950 _pthread_start + 224
25 libsystem_pthread.dylib 0x00007fff2032e47b thread_start + 15
)
2021-03-14 17:01:37.482 python[38483:2301820] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
tick
tick
tick
tick
tick
tick
tick
tick
tick
tick
tick
^C^CException ignored in: <module 'threading' from '/usr/local/anaconda3/lib/python3.7/threading.py'>
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.7/threading.py", line 1308, in _shutdown
lock.acquire()
KeyboardInterrupt
I really want my renderer to be in a separate thread.
So much cleaner!
Can it be done?
This doesn't answer the question, but it solves the problem:
import cv2
import numpy as np
from time import sleep
import threading
import time
bitmap = np.zeros((512,512,3),np.uint8)
def update_bitmap():
for i in range(512):
bitmap[i,i,:] = 128
sleep(1/32)
def main():
threading.Thread(target=update_bitmap).start()
hz = 30
delta_t = 1 / hz
t = time.time()
try:
while True:
sleep(0.001)
if time.time() > t+delta_t:
t += delta_t
cv2.imshow("Color Image", bitmap)
cv2.waitKey(1)
except KeyboardInterrupt:
cv2.destroyAllWindows()
exit(0)
main()
macOS - mojave
,
opencv-python = 4.1.0.25
, python = 3.5.6
When I try to open the webcam to capture the image through opencv in macOS-Mojave, I am constantly getting this error.
But running the same script in ubuntu and windows, there is no error I encounter.
Here is my test code
'''
detector = cv2.CascadeClassifier(cascade)
window_name = "Capture"
cv2.namedWindow(window_name, cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
vs = cv2.VideoCapture(0)
vs.set(3, 1280)
vs.set(4, 720)
time.sleep(2.0)
total = 0
msg = "Enter your Name"
title = "Siamese Network Training Module"
fieldNames = ["Name"]
fieldValues = []
**fieldValues = multenterbox(msg,title, fieldNames)**
folder_names = fieldValues[0]
new_output_folder = output + folder_names
print(new_output_folder)
'''
and this is the error at bold line highlighted above
'''
First throw call stack:
(
0 CoreFoundation 0x00007fff4a599a7d __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff74c6aa17 objc_exception_throw + 48
2 CoreFoundation 0x00007fff4a613886 -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x00007fff4a53b8ef ___forwarding___ + 1485
4 CoreFoundation 0x00007fff4a53b298 _CF_forwarding_prep_0 + 120
5 libtk8.6.dylib 0x000000012717d31d TkpInit + 413
6 libtk8.6.dylib 0x00000001270d517e Initialize + 2622
7 _tkinter.cpython-35m-darwin.so 0x00000001171799f6 _tkinter_create + 1174
8 python 0x000000010b84455e PyCFunction_Call + 62
9 python 0x000000010b90bec7 PyEval_EvalFrameEx + 18583
.
.
.
.
42 python 0x000000010b957eee PyRun_SimpleFileExFlags + 382
43 python 0x000000010b97cd86 Py_Main + 3622
44 python 0x000000010b7be861 main + 497
45 libdyld.dylib 0x00007fff764383d5 start + 1
46 ??? 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
'''
Please let me know what can be done. Thanks
I'd like to check out matlab engine for Python. I installed it according to the directions here. But just the line
import matlab.engine
causes my program to quit with exit code 139, which I understand is some kind of memory fault. I'm running Python 2.7.10 (the Anaconda 2.3.0 distribution), Matlab 2014b, MacOS 10.10, x86_64.
Edit: Here is the stack trace.
* thread #1: tid = 0x1b1703, 0x0000000000000000, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x0000000000000000
frame #1: 0x0000000104eab0dd libpython2.7.dylib`PyEval_GetGlobals + 23
frame #2: 0x0000000104eba62b libpython2.7.dylib`PyImport_Import + 137
frame #3: 0x0000000104eb8d27 libpython2.7.dylib`PyImport_ImportModule + 31
frame #4: 0x00000001028e2063 matlabengineforpython2_7.so`initmatlabengineforpython2_7 + 19
frame #5: 0x00000001000df8d1 libpython2.7.dylib`_PyImport_LoadDynamicModule + 177
frame #6: 0x00000001000dd60b libpython2.7.dylib`import_submodule + 315
frame #7: 0x00000001000ddaba libpython2.7.dylib`load_next + 234
frame #8: 0x00000001000de470 libpython2.7.dylib`PyImport_ImportModuleLevel + 336
frame #9: 0x00000001000bc023 libpython2.7.dylib`builtin___import__ + 131
frame #10: 0x00000001000c39bd libpython2.7.dylib`PyEval_EvalFrameEx + 24989
frame #11: 0x00000001000c5ca3 libpython2.7.dylib`PyEval_EvalCodeEx + 2115
frame #12: 0x00000001000c3d10 libpython2.7.dylib`PyEval_EvalFrameEx + 25840
frame #13: 0x00000001000c5ca3 libpython2.7.dylib`PyEval_EvalCodeEx + 2115
frame #14: 0x00000001000c5dc6 libpython2.7.dylib`PyEval_EvalCode + 54
frame #15: 0x00000001000dc0f0 libpython2.7.dylib`PyImport_ExecCodeModuleEx + 208
frame #16: 0x00000001000dce92 libpython2.7.dylib`load_source_module + 626
frame #17: 0x00000001000dddf0 libpython2.7.dylib`load_package + 400
frame #18: 0x00000001000dd60b libpython2.7.dylib`import_submodule + 315
frame #19: 0x00000001000ddaba libpython2.7.dylib`load_next + 234
frame #20: 0x00000001000de4bc libpython2.7.dylib`PyImport_ImportModuleLevel + 412
frame #21: 0x00000001000bc023 libpython2.7.dylib`builtin___import__ + 131
frame #22: 0x000000010000c7b2 libpython2.7.dylib`PyObject_Call + 98
frame #23: 0x00000001000bc567 libpython2.7.dylib`PyEval_CallObjectWithKeywords + 87
frame #24: 0x00000001000c1366 libpython2.7.dylib`PyEval_EvalFrameEx + 15174
frame #25: 0x00000001000c5ca3 libpython2.7.dylib`PyEval_EvalCodeEx + 2115
frame #26: 0x00000001000c5dc6 libpython2.7.dylib`PyEval_EvalCode + 54
frame #27: 0x00000001000eb17e libpython2.7.dylib`PyRun_FileExFlags + 174
frame #28: 0x00000001000eb41a libpython2.7.dylib`PyRun_SimpleFileExFlags + 458
frame #29: 0x000000010010248d libpython2.7.dylib`Py_Main + 3165
frame #30: 0x0000000100000f54 python`start + 52
Edit 2: I'm not sure which kind of trace is more helpful, but I also tried generating a trace with the trace_calls function defined here. These were the last few lines of that:
Call to dirname on line 120 of /Users/katherine/anaconda/lib/python2.7/posixpath.py from line 38 of /Users/katherine/anaconda/lib/python2.7/site-packages/matlab/engine/__init__.py
Call to import_module on line 20 of /Users/katherine/anaconda/lib/python2.7/importlib/__init__.py from line 42 of /Users/katherine/anaconda/lib/python2.7/site-packages/matlab/engine/__init__.py
Call to import_module on line 20 of /Users/katherine/anaconda/lib/python2.7/importlib/__init__.py from line 58 of /Users/katherine/anaconda/lib/python2.7/site-packages/matlab/engine/__init__.py
Does anyone have any idea how I can fix this?
Thanks very much for any help you can provide.
I'm trying to mount a Tornado server on an Ubuntu VM, whose task will be to generate a complete font pack, starting from a .svg file.
I have run the following script without my server, that worked kinda perfectly.
https://gist.github.com/jorgegarciadev/6127832
And now that I try to execute this task on my server, Fontforge seem to have trouble with the .svg file. First I thought it was a chunk problem, as if my file wasn't read or sent totally, but when I open the recently uploaded file on the server, it's complete and has the same size than the original file. And what's still more disturbing is that Fontforge informs me that this file is not a font file. That's what made me think about the chunk thing (because it seems to be parsing errors)
SVG File on pastebin right there :
http://pastebin.com/ai5pr1DG
The python server code:
import tornado, tornado.ioloop, tornado.web
import os, uuid
import fontforge, re, zipfile
__UPLOADS__ = "uploads/"
EXTS = [".woff", ".ttf", ".otf", ".svg", ".eot"]
class Userform(tornado.web.RequestHandler):
def get(self):
self.render("fileuploadform.html")
class Upload(tornado.web.RequestHandler):
#staticmethod
def cssGenerator(name, fullname):
cssFile = name + ".css"
template = "#font-face {\
\n\tfont-family: '" + fullname + "';\
\n\tsrc: url('" + name + ".eot');\
\n\tsrc: url('" + name + ".eot?#iefix') format('embedded-opentype'),\
\n\turl('" + name + ".woff') format('woff'),\
\n\turl('" + name + ".ttf') format('truetype'),\
\n\turl('" + name + ".svg#ywftsvg') format('svg');\
\n\tfont-style: normal;\
\n\tfont-weight: normal;\
\n}\n\n"
open(cssFile, 'w+').writelines(template)
#staticmethod
def fontGenerator(filename):
#exts = ["woff", "ttf", "otf", "svg", "eot"]
name = os.path.splitext(filename)[0]
'''if not os.path.exists(name):
os.makedirs(name)'''
font = fontforge.open(filename)
fullname = font.fullname
for ext in EXTS:
f = name + ext
font.generate(f)
def post(self):
fileinfo = self.request.files['filearg'][0]
fname = fileinfo['filename']
extn = os.path.splitext(fname)[1]
cname = str(uuid.uuid4()) + extn
zname = os.path.splitext(fname)[0]
fh = open(cname, 'w+')
fh.write(fileinfo['body'])
os.system("mv " + cname + " " + zname + extn)
#zname is default, extn is .svg, fname is default.svg, cname is file name in the server
self.cssGenerator(zname, 'testfont')
self.fontGenerator(zname + extn)
application = tornado.web.Application([
(r"/", Userform),
(r"/upload", Upload),
], debug=True)
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Output after launching server and clicking "upload" button on the client:
strippedname:/home/bill/proto.svg
/home/bill/proto.svg:109: parser error : AttValue: ' expected
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
/home/bill/proto.svg:109: parser error : attributes construct error
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
/home/bill/proto.svg:109: parser error : Couldn't find end of Start Tag glyph line 109
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
/home/bill/proto.svg:109: parser error : Premature end of data in tag font line 6
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
/home/bill/proto.svg:109: parser error : Premature end of data in tag defs line 5
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
/home/bill/proto.svg:109: parser error : Premature end of data in tag svg line 3
-18 403 -18 L 403 -18 C 352 -18 301 0 251 0 C 225 0 210 15 210 41 C 210 63 225 7
^
Couldn't find a font file named /home/bill/proto.svg
proto.svg is not in a known format (or uses features of that format fontforge does not support, or is so badly corrupted as to be unreadable)
ERROR:tornado.application:Uncaught exception POST /upload (82.225.61.131)
HTTPServerRequest(protocol='http', host='py-fontconv.cloudapp.net', method='POST', uri='/upload', version='HTTP/1.1', remote_ip='82.225.61.131', headers={'Content-Length': '32378', 'Accept-Language': 'en-us,en;q=0.8,fr;q=0.5,fr-fr;q=0.3', 'Accept-Encoding': 'gzip, deflate', 'Host': 'py-fontconv.cloudapp.net', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:28.0) Gecko/20100101 Firefox/28.0', 'Connection': 'keep-alive', 'Content-Type': 'multipart/form-data; boundary=---------------------------191335620930032341323215978'})
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1332, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "tornadofileupload.py", line 53, in post
self.fontGenerator(zname + extn)
File "tornadofileupload.py", line 35, in fontGenerator
font = fontforge.open(filename)
EnvironmentError: Open failed
ERROR:tornado.access:500 POST /upload (82.225.61.131) 283.75ms
If anyone finds out what's missing here, that would be such a relief because I'm really struggling on this one.
You need to flush or close fh after writing to it. The best way to do this is with the with statement:
with open(cname, 'w+') as f:
f.write(fileinfo['body'])
The use of mv on the next line is dangerously insecure. Someone could upload a file with the "name" $(rm -rf *) and that command would be executed. Never use os.system with untrusted input. In this case the shutil module provides alternatives. It's also problematic to use the user-supplied filename as zname directly - it's always better to generate your own filenames instead of using one supplied by the client.