Bottom Page

Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Executing func() from a different folder
#1
Hi,

I've a test.py containing a func(x) in my /home/pi directory.

I need to execute the func(x) from /var/www/html directory with the code "python3 test 0". Said code works within the pi directory but not from outside of it.

I've given the www-data group permissinon to test.py but cannot solve the path '/home/pi' issue.

Any help is appreciated.
You like this post
Quote
#2
Did you also give permissions for the /home/pi directory?

Also do you need to run it exactly with this line?
python3 test 0
You should specify the path:
python3 /home/pi/test.py 0
You like this post
Quote
#3
Thanks. Not sure if it's the right way but I solved my issue by creating a local file point to the original located in a different folder as such:

#!/usr/bin/env python

import sys
sys.path.insert(0, '/home/pi/.')

from gpio import ledsOn

if __name__ == '__main__':
  n = int(sys.argv[1])
  print(ledsOn(n))
You like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  call func from dict mcmxl22 3 366 Jun-21-2019, 05:20 AM
Last Post: snippsat
  About [from FILE import FUNC] Nwb 7 414 Apr-21-2019, 02:46 PM
Last Post: snippsat
  Delete directories in folder is not working after folder is updated asheru93 2 256 Feb-13-2019, 12:37 PM
Last Post: asheru93
  How can I return my list from a func? Mike Ru 3 632 Oct-22-2018, 01:15 PM
Last Post: buran
  copy content of folder to existing folder shlomi27 0 472 Aug-11-2018, 01:44 PM
Last Post: shlomi27
  list func in lambda mepyyeti 1 989 Mar-10-2018, 09:07 PM
Last Post: buran
  return variable in func mepyyeti 1 570 Mar-01-2018, 02:30 AM
Last Post: Larz60+
  How to get parent directory from existing func not user func ? harun2525 3 1,737 May-15-2017, 04:47 PM
Last Post: harun2525

Forum Jump:


Users browsing this thread: 1 Guest(s)