Skip to content

unpack into subdirectories __kivy_root__ of private and external storage...#350

Closed
denys-duchier wants to merge 3 commits into
kivy:masterfrom
denys-duchier:fix-recursive-delete
Closed

unpack into subdirectories __kivy_root__ of private and external storage...#350
denys-duchier wants to merge 3 commits into
kivy:masterfrom
denys-duchier:fix-recursive-delete

Conversation

@denys-duchier

Copy link
Copy Markdown
Contributor

....

Since unpacking performs first a recursiveDelete, everything stored in an
unpack root is lost after an app update. In order for e.g. a database on
private storage to persist across app updates it was necessary to make
the private unpack root a subdirectory of private storage rather than
the top level.

@denys-duchier

Copy link
Copy Markdown
Contributor Author

This PR is not finished. I have not touched PythonService.java because I don't really know what that is yet. As I am an Android novice, I would appreciate any help, tips, or pointers that you may provide.

@denys-duchier

Copy link
Copy Markdown
Contributor Author

I have tested service support and it appears to work.

File main.py:

from kivy.app import App
from kivy.lang import Builder
from android import AndroidService

class MyApp(App):

    service = None
    labels = ["hello", "world"]
    flag = False

    def build(self):
        return root

    def start_service(self):
        if not self.service:
            self.service = AndroidService("Python For Android Test Service", "running")
            self.service.start(self.labels[int(self.flag)])
            self.flag = not self.flag

    def stop_service(self):
        if self.service:
            self.service.stop()
            self.service = None

    def on_stop(self):
        self.stop_service()

root = Builder.load_string("""
BoxLayout:
    orientation: "vertical"
    Button:
        text: "Start"
        on_release:
            app.start_service()
    Button:
        text: "Stop"
        on_release:
            app.stop_service()        
""")

MyApp().run()

File service/main.py:

import os
import time

arg = os.getenv('PYTHON_SERVICE_ARGUMENT')

while True:
    print("=== Python Service:", arg)
    time.sleep(0.5)

So, unless you see something I missed, I'd say this PR is ready.

@olymk2

olymk2 commented Apr 16, 2015

Copy link
Copy Markdown
Contributor

@denys-duchier as prommised
Tested this against my app on my tablet and everything still seems to be working.
hope it helps you get it merged.

@denys-duchier

Copy link
Copy Markdown
Contributor Author

@olymk2 thanks a lot!

@tito

tito commented May 16, 2015

Copy link
Copy Markdown
Member

This was needed, even if the name__kivy_root__ is far too long for that. a Simple k/ directory or .root/ or anything else simpler might help.

Can you try to rebase your branch? It cannot be merged :(

Thanks!

@denys-duchier

Copy link
Copy Markdown
Contributor Author

Ok, I rebased and tested and it still works for me. I chose __kivy_root__ to minimize the risk of accidental conflict with application data. If the name really bugs you, it's easily changed. Just tell me the name you want.

@tito

tito commented May 16, 2015

Copy link
Copy Markdown
Member

After discussing with the team, we would like you to rename __kivy_root__ with app. Because it contains the full python libs + your application files as well.

Would you mind to do it?

Thanks!

@denys-duchier

Copy link
Copy Markdown
Contributor Author

there you go: __kivy_root__ -> app

…age.

Since unpacking performs first a recursiveDelete, everything stored in an
unpack root is lost after an app update.  In order for e.g. a database on
private storage to persist across app updates it was necessary to make
the private unpack root a subdirectory of private storage rather than
the top level.
@denys-duchier denys-duchier force-pushed the fix-recursive-delete branch from 1e7928b to b75c435 Compare May 18, 2015 13:09
@inclement

Copy link
Copy Markdown
Member

It looks like this was finished, but never merged. Does anyone have any objections if I apply it to the old toolchain, and port to the new one?

@ecdsa

ecdsa commented Mar 8, 2016

Copy link
Copy Markdown

I have been testing this with the old_toolchain branch.
It works, but I get the following error in the log:

03-08 08:08:12.920 15045 15061 I python  : Initialize Python for Android
03-08 08:08:12.966 15045 15061 I python  : Traceback (most recent call last):
03-08 08:08:12.967 15045 15061 I python  :   File "<string>", line 23, in <module>
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site.py", line 563, in <module>
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site.py", line 545, in main
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site.py", line 278, in addusersitepackages
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site.py", line 253, in getusersitepackages
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site.py", line 243, in getuserbase
03-08 08:08:12.967 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/sysconfig.py", line 520, in get_config_var
03-08 08:08:12.968 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/sysconfig.py", line 419, in get_config_vars
03-08 08:08:12.968 15045 15061 I python  :   File "/opt/electrum/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/sysconfig.py", line 287, in _init_posix
03-08 08:08:12.968 15045 15061 I python  : IOError: invalid Python installation: unable to open /data/user/0/org.electrum.electrum/files/lib/python2.7/config/Makefile (No such file or directory)

apparently it expects the old path in that initialization.
the error does not prevent the app from running

@ecdsa

ecdsa commented Mar 8, 2016

Copy link
Copy Markdown

another issue:
when an already installed app is updated with this PR for the first time, its existing directory is not cleaned up
this results in all files being duplicated.

@inclement

Copy link
Copy Markdown
Member

Closing since this is now resolved.

@inclement inclement closed this Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants