Python bindings for libparted? - python

I'm looking for a way to interact with the GNU libparted library from Python, but so far what I've found, a GSOC project from 2005 and an Ubuntu/debian package that's been dropped from the archive, have been disheartening.
Is there something I'm missing, or should I just get used to manipulating libparted from the command line / trying to fix the bitrot that's occurred in the other packages?

You mean like the pyparted library?

The reason debian dropped the package is lack of a maintainer. If you are willing (and able) to maintain the existing package and become their maintainer that would be a great contribution to FOSS.

You can try using SIP to generate a Python binding for it. It works for QT so it may work for libparted.

Old thread, but you can also checkout reparted, it's a ctypes python binding.

Related

What versions of Python will work in Windows XP?

I would like the most advanced version of Python that still works on Windows XP. I need both Python 2 and Python 3.
What versions of Python will work on Windows XP?
I found that Python 2.7.9 and Python 3.4.4 are the newest versions of Python that work in Windows XP. I found this out through trial and error.
I've found a desperate guy (Daniel Pistelli) who didn't give up at the windows error dialog:
https://ntcore.com/?p=458
I like how he approaches the topic:
If we try to start any new application on XP, we’ll get an error
message informing us that it is not a valid Win32 application. This
happens because of some fields in the Optional Header of the Portable
Executable.
[...]
Fortunately, it’s enough to adjust the fields in the executable we want to start (python.exe), there’s no need to adjust the DLLs as well. If we try run the application now, we’ll get an error message due to a missing API in kernel32. So let’s turn our attention to the imports.
And then he goes on for another 5-6 screens. To sum it up, apparently you'll have to:
Modify the python.exe header,
Run a tiny Python script to remap some DLL calls,
Recalculate some binary hashes,
Create a fake kernel32.dll with certain calls forwarded,
Modify python37.dll to point to this fake thing,
and then you're all set. To be honest I couldn't quite follow (let alone verify!) some of the steps but it looks legit and there are links with Daniel's half-baked solutions for the harder parts, also a lot of Python sources explained. I will definitely give this thing a try.
In fact, here are the final scripts from his GitHub page:
https://github.com/dpistelli/xptmrt
Moral of the story: you can be crazy, but you'll never be dismantle-all-dlls-and-exes-and-open-hexeditors-and-disassemble-hashing-algorithms-and-mock-it-all-together-so-it-works-under-xp-crazy!
Someone had built Python 3.4.10, which is slightly newer than the officially prescribed Python3 v3.4.3/3.4.4 for Windows XP. Since it comes from the third-party (not the official Python website), use at your own risk,
-->Download<--
i tried 3.3.3 but i came up with an error message use 3.4.3/2.7.9 they are the only versions that work now sadly
There are several custom builds of Python >3.44 suitable for Windows XP. A poster at reddit has provided Python 3.55 here:
https://www.reddit.com/r/Python/comments/3tgi0t/python_35_x86_on_windows_xp/
Here is an XP compatible build of 3.6.15 source code only:
https://alex-free.github.io/winxp_python3.6.15/
At the MSFN forums someone has provided an XP compatible build of 3.8.1350 here:
https://msfn.org/board/topic/183741-python-3813-for-windows-xp-sp3/
Official website says about 3.4.10: https://www.python.org/downloads/release/python-3410/
Any of them, python is very platform independent. Some features might not work, but that would best be found in the documentation.

netbeans 7.1 and python

I used to use my Netbeans 6.9 for Python development. As well as Java and PHP. I had a cool debugger in PHP with xDebug, good Python support. Have no complaints whatsoever. I moved to another computer downloaded the latest netbeans(7.1) and now I have no more python plugin. I tried the solution here but this caused NetBeans not to start at all after the loading splash screen is finished NetBeans crashes.
Is there any way I can still code in Python with netbeans?
Thank you in advance
Ok, I fixed this. Say you've screwed up your netbeans installation by installing the pythonplugin then this might just work for you, provided you're using a non-windows OS. This is because Windows uses precompiled binaries to start the Netbeans IDE.
The problem that I solved is that, by default, a set of classes is not added to the Java classpath, which results in a crash. You can find whether this is also your problem by inspecting .netbeans//var/log/messages. If it displays some ClassNotFoundExceptions then we might have the same problem. If not, then at least you've got some pointers on what's going wrong and perhaps you might come up with some solution yourself. ;)
The java classpath is constructed in the file:
/<path>/<to>/<your>/<netbeans>/<installation>/platform/lib/nbexec
On OSX, this could be:
/Applications/NetBeans/NetBeans 7.1.app/Contents/Resources/NetBeans/platform/lib
In the main loop the function construct_classpath is called, which in turn calls the function build_classpath for two directories. I changed the function to this:
build_cp() {
base="$1"
append_jars_to_cp "${base}/lib/patches" "patches"
append_jars_to_cp "${base}/lib" "lib"
append_jars_to_cp "${base}/lib/locale" "locale"
# Added by me:
append_jars_to_cp "${base}/modules/ext" "ext"
}
After that modification, start your IDE and everything should work fine. Good luck!
The Solution for this problem could be found here
http://sahanlm.blogspot.com/2012/12/netbeans-7-2-crash-on-start.html
I am currently using the developer plugins on Netbeans 7.0.1 with no problem. Maybe they simply aren't compatible with the new version yet. I'd suggest just getting a 7.0 and using that.
Add org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar at
C:\Program Files\NetBeans 7.1.1\platform\lib\locale. Start NetBeans, remove the plugin or the reference with problem, later on, delete org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar
Please see the following link. It works for me:
http://wiki.netbeans.org/PythonInstall
Currently your NetBeans/Python choices are:
Try the latest development build updates against your current NetBeans version and mess with breakage at times as noted on the PythonInstall NetBeans wiki page or the link you gave.
Install the latest development version, but realize it's not a stable public release.
Wait for someone in the community to step up with continued development to keep the existing plugin in step with the latest public NetBeans release.
Install the NetBeans 6.9 (or older) version you were using with no complaints just for Python work.
I have had success with older versions and the development build. I am dabbling with other Python aware IDEs while I wait for main stream support, but I've stopped holding my breath.
If you can't change nbexec, like suggested by Bas Jacobs (e.g. on Windows), or don't want to do that, you can use the --cp:p startup parameter to append the necessary JARs to the classpath.
I only had to add the org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar file, so the complete command line under windows now looks like this:
"C:\Program Files\NetBeans 7.1\bin\netbeans.exe" --cp:a C:\\Users\\_YOUR_USERNAME_\\.netbeans\7.1\modules\ext\org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar

Documentation for gnomekeyring Python lib

Is there a documentation for Python 'gnomekeyring' lib somewhere in the Web?
There is the reference for the C library which the Python package uses. Most function names are identical (except for the "gnome_keyring_" prefix). The Bending Gnome Keyring with Python blog series should give you a good start as well.
And as the keyring package was already mentioned: If I remember correctly, that package supports gnome-keyring as a backend, so you can look at its source code to find out how to use gnome-keyring.
Apparently not. But this one is documented, maybe that's an option?
http://pypi.python.org/pypi/keyring
If not, maybe you can figure out how to use gnomekeyring from reading the source of keyring. :)

Distributing a Python library (single file)

For my project I would be using the argparse library. My question is, how do I distribute it with my project. I am asking this because of the technicalities and legalities involved.
Do I just:
Put the argparse.py file along with
my project. That is, in the tar file for my project.
Create a package for it for my
distro?
Tell the user to install it himself?
What's your target Python version? It appears that argparse is included from version 2.7.
If you're building a small library with minimal dependencies, I would consider removing the dependency on an external module and only use facilities offered by the standard Python library. You can access command line parameters with sys.argv and parse them yourself, it's usually not that hard to do. Your users will definitely appreciate not having to install yet another third party module just to use your code.
It would be best for the user to install it so that only one copy is present on the system and so that it can be updated if there are any issues, but including it with your project is a viable option if you abide by all requirements specified in the license.
Try to import it from the public location, and if that fails then resort to using the included module.
You could go with Ignacio's suggestion.
But... For what it is worth, there's another library for argument parsing built into Python, which is quite powerful. Have you tried optparse? It belongs to the base Python distribution and has been there for a while...
Good luck!

Why is the compiler package discontinued in Python 3?

I was just pleasantly surprised to came across the documentation of Python's compiler package, but noticed that it's gone in Python 3.0, without any clear replacement or explanation.
I can't seem to find any discussion on python-dev about how this decision was made - does anyone have any insight inot this decision?
I believe the functionality is now built in:
compile
ast
To provide specific references to the decision trail:
https://mail.python.org/pipermail/python-3000/2007-May/007577.html
PEP 3108
And, for what it's worth, I started Python3 port of the compiler package, to be maintained outside of the stdlib:
https://github.com/pfalcon/python-compiler
https://pypi.org/project/python-compiler/
For what it's worth, I started a port of the compiler package to Python3: https://github.com/pfalcon/python-compiler . At the time of writing, it generates bytecode compatible with CPython3.5, and can compiler entire standard library of that version.

Categories