When I have a some crash report including some MacOSX library (in this case, I'm mostly interested in Python), how can I get more info about it? The library does not contain the debugging information, so the crash report lacks line numbers and other useful stuff. Can I get the debugging information elsewhere and reconstruct the line numbers?
You may want to look at the lldb debugger. It is scriptable in python and pretty easy to do things like symbolicating a crash report. There is even an included example python script that can symbolicate a standard Mac OS X crash report (assuming you have dSYMs for some of the frameworks) and provide file name & line number information.
See http://lldb.llvm.org/symbolication.html for more information about using this, or it is easy to write your own python scripts with lldb. You can make a python method that is called from an lldb session (like lldb.macosx.crashlog does), or you can write a standalone python script that loads lldb and does whatever you want. lldb is structured like a library (a framework on Mac OS X), the lldb command-line command is one possible client of LLDB.framework.
Related
I have been searching for an answer for quite some time and I cannot figure out a robust solution: I have a C# application (on Unity) which needs to call some python functions and libraries. In particular, the python code needs to read a very large tabular file from C# -the equivalent of a large pandas dataframe-, avoiding writing and reading through a file if possible, because given the size it would reduce the performance.
I am a total beginner to C#/Unity, and I have given a look at the following workarounds:
IronPython: it is not an option because the last stable version is for python 2.7. My requirements are python 3.6 and higher, moving towards 3.8.
PyInstaller: it creates .exe files and not .dll. Moreover, it is not clear to me how you could call the executable from C# and pass a dataframe/2D array without writing it on disk. I am also not sure whether it can be called passing an entire input file as argument, if you really want to communicate via files.
Communication via socket: I am a bit lost about it. If this is really feasible on both python and Unity sides, I am happy to see your tutorials -especially for Unity!
Unity Python script editor: it works fine in dev mode. However, the python scripts cannot be included in the build. This: https://forum.unity.com/threads/python-for-unity-editor-only.914843/#post-8330904 seems very suboptimal for a stable build.
Thank you for any hint!
(Before marking as duplicate make sure you understand what this question is about)
I have an application that has a Python API, and I want to ship the Python interpreter which would enable users to run Python in interactive mode. The shipped Python will contain my package pre-installed.
The application is written in Java, but I did not want to couple the shipped Python and the application if possible - I wanted to have a self-contained binary that allows running Python in interactive mode and then having my application referencing it. Bottom line is I wanted a way to ship Python itself in a self-contained way, that is a good way to phrase it.
Just to further clarify - the purpose is not to ship a binary with a compiled Python script using something like pyinstaller or freezing tools, as I have found on many duplicate threads such as Shipping interpreter with Python application, Embed Python interpreter in a Python application, How to bundle a Python application including dependencies? and others. The user being able to use Python in interactive mode is a hard requirement.
So, again, the whole point here is being able to run the shipped Python in interactive mode with some pre-installed dependencies, in which case I think the solutions I have found so far (some of them referenced above) are not robust/self-contained enough. Let me know if I am missing something, which might be the case.
I have a Python console program, which uses input() from builtin to read data from the user. The program has a configuration option, which requires the user to input several paths. I would like to ease these inputs e.g. by a tab-completion.
Is it possible to implement an auto completion e.g. for path names? I see currently no way to hook into the input function to catch tab events/key presses...
Does the Python standard library provide such a feature?
The solution must work on Windows, Linux and Mac OS :).
Please note: I'm not looking for auto completion in Pythons interactive shell/console.
CLI Autocompletion is not included in Python standard library.
You can try:
urwid (http://urwid.org/tutorial/index.html) for a rather low level CLI library
Cement for a full CLI framework (http://cement.readthedocs.io and http://cement.readthedocs.io/en/latest/examples/bash_auto_completion/)
In all cases it's probably quite a bit of work :-/
I am currently interning at a place where they've asked me to make a standalone python program to do something (say X).
Now, that program is to be run by some commands sent by their proprietary software which is written in their proprietary language. Now the reason I'm saying proprietary so many times is because they aren't ready to take me anywhere near their code. I am just supposed to make a Python code that does X based on the input given by their software.
So is there a way I can make an API and wrap it around my code so as to let the software control it? Also I need to make the whole thing standalone (maybe an installer of some kind) so that they don't have to install Python and the accompanying modules (like opencv) just to run my script?
All I could get out of them was "there are dll files that will be calling your app and we want an executable"
Any programm can execute any other program (if it has the appropriate rights) so there is no real distinction between "python file" and "python executable" (that is because python is an interpreted language. The python source files and the "final python program" are "identical" (asuming cpython), in contrast to e.g. a C program where the source files and the executable are vastly different).
If you are on windows there is the additional problem that the user must have installed python to execute .py files. There are some ways to mitigate that problem - there are python libraries that "freeze" the python interpreter and your code into a single .exe file (from the comment by Bakuriu see e.g. freeze) . You could bundle the python interpreter with your code. You can just say your users to install python (if the amount of users is low that might be the good way).
"API" is just a fancy way of saying "this is how you communicate with my programm". This might be how you call a library (e.g. what functions a python module exports) or this might be an HTTP API or which command line arguments are passed or which protocoll over an TCP socket is spoken. Without knowing which API you are supposed to implement you cannot fulfill your job.
Without knowing further specifications (what inputdoes the other program give to yours, how does it call your programm?) it's very hard to say anything more helpful.
I have written an application that gives the user an option to specify a particular network scanning tool (say nmap,xprobe,p0f) and then scans a given subnet with that tool (I do not re-implement the tool, simply call it in shell and parse its response for my app), parses the result and stores in a particular format in DB. This application is basically a feeder application for another app that will use the data in DB.
I have written my code so that all Scan Tool interfaces are implemented as plug-ins. The structure is
Project/
DBWriter.py
Scanner/
__init__.py
network_mapper.py
Scanner.py
Plugins/
__init__.py
nmap.py
p0f.py
Others/
So to add a new scan interface, all the developer needs to do is write a tool.py file (in correct semantics ofcourse) and drop it into Plugins folder.
To achieve this I need to be able to import correct python module at run-time.
from Plugins import nmap
or
from Plugins import xprobe
Depending on what the user enters
Here's the code that I have added
f,p,d = imp.find_module("Plugins")
x = imp.load_module("Plugins",f,p,d)
path_n = x.__path__
f,p,d = imp.find_module("%s"%(tool),path_n)
tool_mod = imp.load_module("%s"%(tool),f,p,d)
tool_mod.scan() #Irrespective of what user enters or what new plugin is developed, this line does not need to change and will work as long as plug-in has a scan function
The code works correctly. However, when I try to bundle it into one executable using PyInstaller (for Windows/*Nix platforms), it has a lot of trouble in find_module and load_module and consequently I get an ImportError (maybe its because the paths are not correctly unrolled in executable decompression).
My question is - Is there an alternate way in Python using which I can achieve the same functionality (that might hopefully work well with PyInstaller) ?
I had earlier asked this question looking for workarounds in PyInstaller, but no responses have forced me to look for workarounds in Python
If you only need to run on Windows, then I recommend trying py2exe.
py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.
We use it at work to speed up a very large Python program, and it copes with imported modules.