Forum Archive

File parts error running apps via home shorcut

CastroSATT

Hiya guys taking a break from the pdf issue I had,, I think I found a solution but it’s on a take me a week or so to implement... so on to the easier issue

I have an app that uses a load of subvies etc also uses a few folder for templates and invoices also got a folder for sound effects banners etc

No the issue is works fine when I run the script from within pythonista... but if I run from shortcut straight into the app I get file not found errors it’s almost as if the app can not see its file paths

And help would be great

This is a pic of the error

https://drive.google.com/file/d/1KyJGl9R7DdBXhh1JRl45r34mAXsEhhhT/view?usp=drivesdk

afelix

Can you include a snippet of your code, and the way you attempt to view that path? Do you use os.path.expanduser for example? Based on the image I would say you're trying to call a path relative to a directory, but when running from the shortcut it might not know how to find it. It's safer to call it relative from the user directory, then use os.path.expanduser to solve the path.

CastroSATT

Cool

Here’s a snippet really it’s for reading and writing the ini file

For example Same command used but for the sound fx

def SoundFx(N):
    if N == 1:
        # Honour position of phone silent switch  
        sound.set_honors_silent_switch(True)
        # sets volume 
        sound.set_volume(1.0)
        #preloads 
        sound.load_effect('./RR/img/hadouken.mp3')
        #sample to be played when imaged pressed
        sound.play_effect('./RR/img/hadouken.mp3')
        vibrate()

CastroSATT

Looks like that would work not sure how to implement it if you got any clues a am full beginnerish

cvp

@CastroSATT Is your script in the root?

Begin your script with

import os
print(os.listdir())

Only to check the difference when you run in Pythonista and from an home screen shortcut

mikael

@CastroSATT

import os.path
my_sounds_dir = os.path.expanduser('~/Documents/dir_where_the_script_is_now/RR/img/')
sound.load_effect(my_sounds_dir+'hadouken.mp3')