I ran a Website on Zope/Plone for several years, until the server crashed catastrophically. I have no interest in bringing up the Web site again (nor am I convinced that I even could, since the version of both Zope and Plone that it was based on has been obsolete for at least six years), but I'd love to be able to get the content out so that I can use it. It's stored in a Zope filesystem (i.e. Plone-2.5.3/zeocluster/server/var/Data.fs). Is there any set of tools out there that would allow my to write a Python script to save the content to files? Or is there another way to get at the content short of attempting to reinstall the whole Web site? Data.fs is over half a gigabyte, so there's a fair bit in there.
I'm running Python 2.7 and 3.4 on Ubuntu 14.04, in case that's relevant.
Bite the bullet and re-install Plone 2.5.3. While you can theoretically read the ZODB, its contents consist of Python pickles which won't make sense without the classes that were pickled.
Re-installing 2.5.3 will have some challenges, but if you start with the "Unified Installer" for 2.5.3 (https://plone.org/products/plone/releases/2.5.3), you'll at least have all the source pieces, including the matching Python.
Once you've got 2.5.3 running again, you'll have the code base you need to read and export the data via Python script.
Zope/Plone uses ZODB for storage. Try that on a copy of Data.fs.
Related
I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suffering, I still haven't been able to make it work!
If I could use python, I'd be able to get it done easily. So, obviously, I want to find a way to get a python script working in Unity. But IronPython is the only thing I've been able to find, and it's outdated.
I need either knowledge of how to make IronPython work in spite of being outdated, or some other method. Please.
Unfortunately, Unity at this time does not support Python. Although, there is an asset that you can use a bit of Python with. I am not sure what you can do with this asset but I know it could help a minimal amount:https://assetstore.unity.com/packages/tools/integration/python-interpreter-645
Quick Note: Most programming languages work about the same way. If you figure out the documentation and grammar/punctuation for C#/UnityC#, you should be off just fine.
I try to use python once on Unity and I found a few ways:
There is a package call "IronPython" where you can add a python file to your unity project and then call a function from C# to your python code, to do that you should follow this:
We already know that we can use python to use .net internal calls.
Now we may use the same to start a console that can accept a scripting language in Unity engine.
To do this we have to include certain dll files.
These dll files must be present in Assets>plugins
IronPython.dll
IronPython.Modules.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Dynamic.dll
Once the Plugins are in place.
Initiate the Cs code
PythonEngine engine = new PythonEngine();
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject)));
engine.ExecuteFile("Test.py");
Where test.py is the python code.
Initiate python side:
import UnityEngine from UnityEngine
import *
Debug.Log("Hello world from IronPython!")
References:
https://github.com/cesardeazevedo/Unity3D-Python-Editor
http://techartsurvival.blogspot.in/2013/12/embedding-ironpython-in-unity-tech-art.html
IronPython in Unity3D
the issue with this way is that most of the python module are not supported.
2.the second way is to create a file like json that contain the data you want to send to the json and then create an output json that send the output from the python script, this way is very limited with what you can send because the data must be contain in your json.
the last way that work for me is to install the Nuget package and copy the script from python to c# line by line with the relevent module installed in Unity and it's work for me, but copy a long code can take time.
this is a reference to the package:
https://github.com/GlitchEnzo/NuGetForUnity
and then to install the relevent package you should press on NuGet → Manage NuGet Packages and the choose the relevent package(for me it was Numpy and it work grate).
hope it will help you
I don't know how recent it is but there is a Unity package for python available on unity 2019.3 and further versions.
Warning the first versions of this package can't use Python3.
You can see more for yourself by the following link.
https://docs.unity3d.com/Packages/com.unity.scripting.python#2.0/manual/index.html
I hope this may help you.
We are thrilled to announce that Python for Unity 4.0.0-exp.5 is now available!
4.0.0-exp.5 is a major upgrade from our last public release, and incorporates a large number of changes. In summary:
Based on Python 3.7; scripts based on Python 2.7 will need to be ported.
Users no longer need to install Python on their system.
In-process Python is no longer reinitialized when the Unity domain reloads.
Removed the out-of-process API. The PySide example now runs in-process and is much simpler.
Limited support for a virtual environment workflow via the ProjectSettings/requirements.txt file.
Many bug fixes.
Documentation for the Python for Unity package is available here, and the full changelog can be found here.
This is an experimental release, and thus is not visible in Package Manager. To install this package, open Package Manager, click the + at the top left and select Add package by name.... Enter com.unity.scripting.python as the name and and 4.0.0-exp.5 as the version and click Add. Alternatively, you may edit Packages/manifest.json and add "com.unity.scripting.python": "4.0.0-exp.5", to the list of dependencies, or edit the existing entry for Python for Unity to update the version.
Soursce: https://forum.unity.com/threads/python-for-unity-release-announcements.1084688/
Documentation: https://docs.unity3d.com/Packages/com.unity.scripting.python#4.0/manual/index.html
Unity not supported python, But you Can write Python Code and run it by Socket programing, Create Server with python and send data,in C# Connect to server and use data sended with python.
I have some experience with Python-Django including its REST framework, a reasonable understanding of geographic information (and what GIS is about) and about databases, and I would like to develop a "geo-aware" REST service on my Windows machine based on Django. The application shall be limited to the REST service; visual exploration and other stuff shall be developed independently. Side-remark: once my application is running, it will be ported onto a Linux machine and PostGIS will then be used instead of SpatialLite.
After several hours of web-searching, I still haven't come up with a good "Quickstart" guide. There are many tutorials and docs about various aspects related to my task, but they either refer to Linux, or their installation instructions are outdated. Here is what I have done so far:
1) I use miniconda and Pycharm
2) I created a new virtual environment like so:
conda create -n locations pip numpy requests
activate locations
conda install -c conda-forge django djangorestframework djangorestframework-gis
3) I set-up the new Django project and my application and performed a database migration:
python [path-to..]\django-admin.py startproject locations
cd locations
python [path-to..]\django-admin.py startapp myapp
cd ..
python manage.py migrate
4) I added "rest_framework" and "myapp.apps.MyAppConfig" to the APPLICATIONS in settings.py
5) I stopped reading the general django-restframework tutorial and began searching for django-restframework-gis specific information. What I understood from this is that I need to enhance my SQLite database to become a SpatialLite database. Windows binaries for SpatialLite are available at gaia-sins -- but which of these do I really need? I downloaded the mod_spatialite-4.3.0a-win-x86.7z file and unpacked it, and I added SPATIALITE_LIBRARY_PATH= '[path-to..]\mod_spatialite-4.3.0a-win-x86\mod_spatialite.dll' to my settings.py.
What comes next?
Specific questions:
1) Do I really need to upgrade my SQLite database if I am not planning to store geospatial information but merely build a REST service to deliver information in GeoJSON which is coming from other sources (for example weather model output in netcdf data format)? Or would it suffice to describe my Django model in this case and simply ignore any database-related issues?
2) What is the minimum code to get the basic "wiring" done? This could be an extremely simple service which would accept a lat/lon coordinate as parameter in the URL and return this location in GeoJSON format. Such code should highlight the differences between using the "normal" django-restframework from the gis version. Once I have this, I will probably find my way through the existing documentation (for example Miguel Grinberg Tutorial or GitHub description).
OK, after another day of searching and experimenting, I acknowledge that this has been the wrong question to ask - therefore I answer myself and close this issue.
Apparently, I have been to naive about setting up a "geo-aware" service, thinking that I can get away with a special datatype or two for coordinates, and a special kind of serializer for GeoJSON - and, if really necessary, with a geo-enabled database.
Turns out, that what I want to do in the end, is a GeoDjango application (even if I will use only a tiny fraction of what GeoDjango can do), and so the GeoDjango docs are the place to start from, and in particular their installation guide.
The story isn't over yet as I am still having troubles to load the required libraries from Django, but the direction is clearer now.
More specifically, the issue I ran into wasn't primarily a SpatiaLite issue. I was able to install SpatiaLite and enhance an existing sqlite database by running SELECT load_extension('mod_spatialite'); SELECT InitSpatialMetaData(); (see also this post. Django (python manage.py check) complained about not finding the gdal library, and once it found it, it was the wrong version. The GeoDjango docs report that this is indeed the most common problem when installing GeoDjango. It would be helpful if the error messages from ctypes were a bit more verbose to make it easier to search for solutions. It took several hops across various web sites and an extra print statement in the ctypes init.py file, before I found out that one needs to match the version of gdal, the version of python, and the compiler (DLL hell this was called by someone).
Another part of the confusion arises from the manifold dependencies among the various required "geo packages". For example, SpatiaLite already comes with a gdal library, so why the need for installing gdal separately? Indeed, the GeoDjango docs recommend to work with OSGEO4W, because this program suite bundles everything together. Yet, this is not trivial if one starts from a system where OSGEO4W and Python/Django have been installed independently. This is the situation I start from. I installed OSGEO4W primarily to work with QGIS, and I installed Python and Django for other tasks. The realisation that the two must be linked for a GeoDjango application only came afterwards. I might need to start from scratch, but it would be good to know if people have been successful in a Windows 10, x64 environment with Python >= 3.4 recently.
I would like to be able to use the services that the Blockcypher module provides for my programme, however i have (at least i think) downloaded the correct module package but cant get it to integrate with my Python on my Computer. I am fairly new to python so I have no idea on where to even start tackling this problem.
Modules, regardless of where you've got hold of them, will be searched for in the sys.path. If nothing is found there, they will be looked up in the current directory.
When you download some code directly it will be a good first guess to place it in the directory of the script from where you are using the download. If it's just a .py-file, place it there. If it's an archive with a directory, then place the directory there (not the files).
Generally, you should prefer installing modules via a package manager such as pip or conda. Such package managers take care of placing modules properly for usage with your Python installation from wherever you will write your script. They also provide support for updating these modules to newer versions later.
Update: If you cannot make anything from this remarks, you should first read the section on modules in the Python tutorial, or even work thru the full tutorial or thru a good book (or any other ;) to get a smooth entry into the friendly world of Python programming.
Update (2023): The Dive Into Python link above is outdated, so here is the updated link to this great resource:
https://diveintopython3.problemsolving.io
I think it's still the best beginner's resource, but, well, here are many more:
https://wiki.python.org/moin/IntroductoryBooks
So it's a new millennium; Apple has waved their hand; it's now legal to include a Python interpreter in an iPhone (App Store) app.
How does one go about doing this? All the existing discussion (unsurprisingly) refers to jailbreaking. (Older question: Can I write native iPhone apps using Python)
My goal here isn't to write a PyObjC app, but to write a regular ObjC app that runs Python as an embedded library. The Python code will then call back to native Cocoa code. It's the "control logic is Python code" pattern.
Is there a guide to getting Python built in XCode, so that my iPhone app can link it? Preferably a stripped-down Python, since I won't need 90% of the standard library.
I can probably figure out the threading and Python-extension API; I've done that on MacOS. But only using command-line compilers, not XCode.
It doesn't really matter how you build Python -- you don't need to build it in Xcode, for example -- but what does matter is the product of that build.
Namely, you are going to need to build something like libPython.a that can be statically linked into your application. Once you have a .a, that can be added to the Xcode project for your application(s) and, from there, it'll be linked and signed just like the rest of your app.
IIRC (it has been a while since I've built python by hand) the out-of-the-box python will build a libPython.a (and a bunch of other libraries), if you configure it correctly.
Of course, your second issue is going to be cross-compiling python for ARM from your 86 box. Python is an autoconf based project and autoconf is a pain in the butt for cross-compilation.
As you correctly state, making it small will be critical.
Not surprising, either, is that you aren't the first person to want to do this, but not for iOS. Python has been squeezed into devices much less capable than those that run iOS. I found a thread with a bunch of links when googling about; it might be useful.
Also, you might want to join the pyobjc-dev list. While you aren't targeting a PyObjC based application (which, btw, is a good idea -- PyObjC has a long way to go before it'll be iOS friendly), the PyObjC community has been discussing this and Ronald, of anyone, is probably the most knowledgeable person in this particular area. Note that PyObjC will have to solve the embedded Python on iOS problem prior to porting PyObjC. Their prerequisite is your requirement, as it were.
I've put a very rough script up on github that fetches and builds python2.6.5 for iPhone and simulator.
http://github.com/cobbal/python-for-iphone
Work in progress
Somewhat depressing update nearly 2 years later: (copied from README on github)
This project never really got python running on the iPhone to my
satisfaction, and I can't recommend using it for any serious project
at this stage.
Most notably missing is pyobjc support (which turns out to be much
harder to port to iPhone since it relies on more platform-specific
code)
Also missing is the ability to statically compile modules, (all are
currently built as dylibs which works for development, but to my
knowledge wouldn't be allowed in the App Store)
At this point this project is mostly meant to be a starting point for
anyone smarter than me who wants to and can tackle the above issues.
I really wish it were practical to write apps entirely in Python, but
at this point it seems impossible.
I also started such a project. It comes with its own simplified compile script so there is no need to mess around with autoconf to get your cross compiled static library. It is able to build a completely dependency-free static library of Python with some common modules. It should be easily extensible.
https://github.com/albertz/python-embedded/
Python's imageop module is quite useful in CGI to create thumbnails from uploaded images automatically, but according to its documentation, it's deprecated since 2.6.
I'm working on a shared server, so I can not install PIL, imagemagick or something similar by myself. How else could I create a thumbnail from an uploaded image? Because Javascript can't do that on the client side, not without using canvas, right?
You are right that you can't do that with javascript - not without passing back the whole image content back to the browser.
As for Python - being "deprecated" dos not mean it is removed - it is still around in Python 2.7, and since Python 2.7 will be maintained more or less "forever", as everyone will take some more several years to move to Python 3.x, you can count on imageop being available.
As for installing PIL - which is "the way to go" - you don't have to install it as root - it can be instaled as a unix user. Which means: you need shell access, or at least file deployment access, isntall it on a directory you have write access, and set PYTHONPATH accordingly.
However, it can be tricky to install PIL this way, it can be done - in the worst case (if you have only file write access, but no shell), you'd have to mimic the running environment on your side (for example, having a VM installed with the same library versions that are on your server), and build it there, and then move the files to the server.
Searching for a pure Python way of dealing with images yields PNGCanvas, but it does not have image scaling capabilities. (and can only deal with PNG files, of course).
Another alternative is to make use of a web service to perform image operations for you - yu'd then post the whole image to an app in another server, and retrieve only your thumbnail. Searching for "free image webservice" yields a number of results.