Skip to content

Comments

Support for Termux subsystem#63

Merged
gaborbernat merged 6 commits intotox-dev:mainfrom
YariKartoshe4ka:android-oserror-fix
Feb 9, 2022
Merged

Support for Termux subsystem#63
gaborbernat merged 6 commits intotox-dev:mainfrom
YariKartoshe4ka:android-oserror-fix

Conversation

@YariKartoshe4ka
Copy link
Contributor

Fix of #62

Platformdirs on Termux under Arch Linux subsystem:

-- platformdirs 2.4.2.dev4+gbd70a11 --
-- app dirs (with optional 'version')
user_data_dir: /root/.local/share/MyApp/1.0
user_config_dir: /root/.config/MyApp/1.0
user_cache_dir: /root/.cache/MyApp/1.0
user_state_dir: /root/.local/state/MyApp/1.0
user_log_dir: /root/.cache/MyApp/1.0/log
user_documents_dir: /root/Documents
user_runtime_dir: /run/user/0/MyApp/1.0
site_data_dir: /usr/local/share/MyApp/1.0
site_config_dir: /etc/xdg/MyApp/1.0

-- app dirs (without optional 'version')
user_data_dir: /root/.local/share/MyApp
user_config_dir: /root/.config/MyApp
user_cache_dir: /root/.cache/MyApp
user_state_dir: /root/.local/state/MyApp
user_log_dir: /root/.cache/MyApp/log
user_documents_dir: /root/Documents
user_runtime_dir: /run/user/0/MyApp
site_data_dir: /usr/local/share/MyApp
site_config_dir: /etc/xdg/MyApp

-- app dirs (without optional 'appauthor')
user_data_dir: /root/.local/share/MyApp
user_config_dir: /root/.config/MyApp
user_cache_dir: /root/.cache/MyApp
user_state_dir: /root/.local/state/MyApp
user_log_dir: /root/.cache/MyApp/log
user_documents_dir: /root/Documents
user_runtime_dir: /run/user/0/MyApp
site_data_dir: /usr/local/share/MyApp
site_config_dir: /etc/xdg/MyApp

-- app dirs (with disabled 'appauthor')
user_data_dir: /root/.local/share/MyApp
user_config_dir: /root/.config/MyApp
user_cache_dir: /root/.cache/MyApp
user_state_dir: /root/.local/state/MyApp
user_log_dir: /root/.cache/MyApp/log
user_documents_dir: /root/Documents
user_runtime_dir: /run/user/0/MyApp
site_data_dir: /usr/local/share/MyApp
site_config_dir: /etc/xdg/MyApp

Platformdirs on Termux:

-- platformdirs 2.4.2.dev4+gbd70a11 --
-- app dirs (with optional 'version')
user_data_dir: /data/data/com.termux/files/MyApp/1.0
user_config_dir: /data/data/com.termux/shared_prefs/MyApp/1.0
user_cache_dir: /data/data/com.termux/cache/MyApp/1.0
user_state_dir: /data/data/com.termux/files/MyApp/1.0
user_log_dir: /data/data/com.termux/cache/MyApp/1.0/log
user_documents_dir: /storage/emulated/0/Documents
user_runtime_dir: /data/data/com.termux/cache/MyApp/1.0/tmp
site_data_dir: /data/data/com.termux/files/MyApp/1.0
site_config_dir: /data/data/com.termux/shared_prefs/MyApp/1.0

-- app dirs (without optional 'version')
user_data_dir: /data/data/com.termux/files/MyApp
user_config_dir: /data/data/com.termux/shared_prefs/MyApp
user_cache_dir: /data/data/com.termux/cache/MyApp
user_state_dir: /data/data/com.termux/files/MyApp
user_log_dir: /data/data/com.termux/cache/MyApp/log
user_documents_dir: /storage/emulated/0/Documents
user_runtime_dir: /data/data/com.termux/cache/MyApp/tmp
site_data_dir: /data/data/com.termux/files/MyApp
site_config_dir: /data/data/com.termux/shared_prefs/MyApp

-- app dirs (without optional 'appauthor')
user_data_dir: /data/data/com.termux/files/MyApp
user_config_dir: /data/data/com.termux/shared_prefs/MyApp
user_cache_dir: /data/data/com.termux/cache/MyApp
user_state_dir: /data/data/com.termux/files/MyApp
user_log_dir: /data/data/com.termux/cache/MyApp/log
user_documents_dir: /storage/emulated/0/Documents
user_runtime_dir: /data/data/com.termux/cache/MyApp/tmp
site_data_dir: /data/data/com.termux/files/MyApp
site_config_dir: /data/data/com.termux/shared_prefs/MyApp

-- app dirs (with disabled 'appauthor')
user_data_dir: /data/data/com.termux/files/MyApp
user_config_dir: /data/data/com.termux/shared_prefs/MyApp
user_cache_dir: /data/data/com.termux/cache/MyApp
user_state_dir: /data/data/com.termux/files/MyApp
user_log_dir: /data/data/com.termux/cache/MyApp/log
user_documents_dir: /storage/emulated/0/Documents
user_runtime_dir: /data/data/com.termux/cache/MyApp/tmp
site_data_dir: /data/data/com.termux/files/MyApp
site_config_dir: /data/data/com.termux/shared_prefs/MyApp

def user_data_dir(self) -> str:
""":return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``"""
return self._append_app_name_and_version(_android_folder(), "files")
return self._append_app_name_and_version(_android_folder() or "", "files")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the or here? I've understood that when this is called it's guaranteed that it will be not None, not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tox -e type swears

Copy link
Member

@gaborbernat gaborbernat Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy knows less than we, but probably a typing.cast for mypy likely is better choice than or 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, i think so too

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@BDhackers009 BDhackers009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sir when I put these 2 files manually in _vendor/platformdirs/ folder it fixes my problem😊

@Pairshoe
Copy link

Thanks gentleman, this works for me.

@rishi2004-sudo
Copy link

pls can you tell me which two files are needed to be added to solve this problem.Iam facing this problem in my ubuntu jammy installed in termux using proot-distro.

@brt2cv
Copy link

brt2cv commented Sep 17, 2022

thanks,it works for my termux !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants