Hello Guest, if you are reading this it means you have not registered yet. Please take a second, Click here to register, and in a few simple steps you will be able to enjoy our community and use our OpenViX support section.
Page 1 of 3 123 LastLast
Results 1 to 15 of 36

Thread: changing/downloading files with permissions

  1. #1
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts

    changing/downloading files with permissions

    Hi is there a way to download a file from github with write edit and execute permissions?

    im creating a plugin to download a script from my github
    Code:
    https://github.com/davesayers2014/AutoBouquetsMaker/blob/master/AutoBouquetsMaker/updateProviders.sh
    This downloads fine without errors but I also want to run the script but it doesnt because the permission shows as 644 ive tried os.chmod 0775 and 0777 but it doesnt seem to work here is what I have

    Code:
    def main(session, **kwargs):
    
           if not os.path.exists('/usr/script'):
                  os.mkdir('/usr/script', 0755)
    
           import urllib
           f = urllib.URLopener()
           f.retrieve('https://raw.githubusercontent.com/davesayers2014/AutoBouquetsMaker/master/AutoBouquetsMaker/updateProviders.sh','/usr/script/updaProviders.sh')
           
           import time
           time.sleep(5)
           
           if os.path.exists('/usr/script/updateProviders.sh'):
              os.chmod('/usr/script/updateProviders.sh', 0755)       
    
              os.system('/usr/script/updateProviders.sh &')
    No errors come up and the file has downloaded but this script hasn't ran if I already have the file with 755 and just use
    Code:
    os.system('/usr/script/updateProviders.sh &')
    it runs fine so how can I download the script with the correct permission or change it after downloading? also ive deleted the script folder and ran the plugin and the folders are created with the correct directory just not the script
    Last edited by dsayers; 24-09-16 at 10:19.

  2. #2
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    an update ive uploaded the file in zip hoping I could download it unzip it and place the script in usr/script using this address
    Code:
    https://github.com/davesayers2014/AutoBouquetsMaker/raw/master/AutoBouquetsMaker/updatecustom.rar?raw=true
    but im getting

    Code:
    15:52:02.724 { D }   File "/usr/lib/enigma2/python/Plugins/Extensions/UpdateProviders/plugin.py", line 47, in main
    15:52:02.725 { D }     f.retrieve('https://github.com/davesayers2014/AutoBouquetsMaker/raw/master/AutoBouquetsMaker/updatecustom.rar?raw=true','/usr/script/updaProviders.sh')
    15:52:02.725 { D }   File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
    15:52:02.726 { D }   File "/usr/lib/python2.7/urllib.py", line 213, in open
    15:52:02.726 { D }   File "/usr/lib/python2.7/urllib.py", line 457, in open_https
    15:52:02.726 { D }   File "/usr/lib/python2.7/urllib.py", line 381, in http_error
    15:52:02.727 { D }   File "/usr/lib/python2.7/urllib.py", line 386, in http_error_default
    15:52:02.728 { D } IOError: ('http error', 302, 'Found', <httplib.HTTPMessage instance at 0x71598a80>)
    15:52:02.728 [ E ] python/python.cpp:209 call (PyObject_CallObject(<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0x7158a5d0>>,('SetupActions', 'ok')) failed)
    ive also tried

    Code:
    https://github.com/davesayers2014/AutoBouquetsMaker/blob/master/AutoBouquetsMaker/updatecustom.rar
    but still having the same error

  3. #3
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    ok ive managed to download zip adding catch and downloaded to tmp I just need to get it to unzip and move to usr/script

    im using
    Code:
    zip_ref = zipfile.ZipFile('/tmp/updatecustom.zip, 'r')
    but i get I'm getting EOL while scanning string literal
    if I remove the first ' I end up with invalid syntax error
    Last edited by dsayers; 24-09-16 at 17:49.

  4. #4
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    ok I give up ive done as I wanted downloaded as zip to tmp extracted to usr/script but its now showing permissions 007

    Thanks for the help

  5. #5
    birdman's Avatar
    Title
    Moderator
    Join Date
    Sep 2014
    Location
    Hitchin, UK
    Posts
    7,777
    Thanks
    237
    Thanked 1,658 Times in 1,306 Posts
    Have you tried running the commands one at a time (serially) on the command line first, just to check what the results are without python being in the way and you only seeing the end result of multiple commands?
    In other words, simplify your problem in order to solve it.
    MiracleBox Prem Twin HD - 2@DVB-T2 + Xtrend et8000 - 5(incl. 2 different USBs)@DVB-T2[terrestrial - UK Freeview HD, Sandy Heath] - LAN/USB-stick/HDD

  6. The Following User Says Thank You to birdman For This Useful Post:

    dsayers (25-09-16)

  7. #6
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    Thanks for the reply yes it's only when trying to chmod the script it doesn't work. It creates the directory and chmods it then downloads if I download it directly from github to usr/script it shows permission as 644 if I download in zip to tmp and have it unzip and extract to to usr/script it shows as properties 007. So it's only for chmod to the file. If I manually change the properties to 775 and just use

    Code:
     os.system('/usr/script/updateProviders.sh &')
    it works. My main goal is to be able to use the script in crontimer so we can download the providers files daily or weekly rather than having to manually do it via abm update config files plus we can do the same for my custommix.xml.

  8. #7
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    do you think it needs a longer sleep time to chmod?

  9. #8
    Larry-G's Avatar
    Title
    V.I.P
    Donated Member
    Join Date
    May 2010
    Posts
    32,542
    Thanks
    7,824
    Thanked 22,935 Times in 12,378 Posts
    Quote Originally Posted by dsayers View Post
    ok I give up ive done as I wanted downloaded as zip to tmp extracted to usr/script but its now showing permissions 007

    Thanks for the help
    That was fast, you made a post and 7 1/2 hrs later you give up because no one replied ?. Patience is obviously not a virtue you possess lol.

    (Just taking the piss, try not to take it to heart more people on this forum need to grow a sense of humour lol).
    My posts contain my own personal thoughts and opinions, they do not represent those of any organisation or group but my own.

    If you don't like what I post, Don't read it.

    SIMPLES.

  10. #9
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    No worries I just was tired and hungry lol was messing around with it from about 7 plus took me a couple of days to get to this part

    Sent from my SM-G925F using Tapatalk
    Using a Vu+Uno4k using a sundtek DVB-S/S2 USB tuner with vix 6.4 developer image

  11. #10
    Larry-G's Avatar
    Title
    V.I.P
    Donated Member
    Join Date
    May 2010
    Posts
    32,542
    Thanks
    7,824
    Thanked 22,935 Times in 12,378 Posts
    Quote Originally Posted by dsayers View Post
    No worries I just was tired and hungry lol was messing around with it from about 7 plus took me a couple of days to get to this part

    Sent from my SM-G925F using Tapatalk
    some times it takes a while for people who know how to help to see the threads. A friendly bump every so often won't harm any thing but the majority of users won't know how to help hence no replies.

    (p.s I can't help either just chipping in for a bit of sorely lacking banter, this forum used to be a way friendlier place with far less sticks up people's arses lmao).
    My posts contain my own personal thoughts and opinions, they do not represent those of any organisation or group but my own.

    If you don't like what I post, Don't read it.

    SIMPLES.

  12. The Following User Says Thank You to Larry-G For This Useful Post:

    dsayers (25-09-16)

  13. #11
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    Quote Originally Posted by birdman View Post
    Have you tried running the commands one at a time (serially) on the command line first, just to check what the results are without python being in the way and you only seeing the end result of multiple commands?
    In other words, simplify your problem in order to solve it.
    ive tried using
    Code:
    os.chmod('/usr/script/updateProviders.sh', 0755)       
    
    os.system('/usr/script/updateProviders.sh &')
    and get
    Code:
     "/usr/lib/enigma2/python/Plugins/Extensions/UpdateProviders/plugin.py", line 40, in main
    21:20:29.067 { D }     os.chmod('/usr/script/updateProviders.sh', 0755)       
    21:20:29.067 { D } OSError: [Errno 2] No such file or directory: '/usr/script/updateProviders.sh'
    Evan though it does exist

  14. #12
    birdman's Avatar
    Title
    Moderator
    Join Date
    Sep 2014
    Location
    Hitchin, UK
    Posts
    7,777
    Thanks
    237
    Thanked 1,658 Times in 1,306 Posts
    Quote Originally Posted by dsayers View Post
    ive tried using
    Code:
    os.chmod('/usr/script/updateProviders.sh', 0755)       
    
    os.system('/usr/script/updateProviders.sh &')
    and get
    Code:
     "/usr/lib/enigma2/python/Plugins/Extensions/UpdateProviders/plugin.py", line 40, in main
    21:20:29.067 { D }     os.chmod('/usr/script/updateProviders.sh', 0755)       
    21:20:29.067 { D } OSError: [Errno 2] No such file or directory: '/usr/script/updateProviders.sh'
    Evan though it does exist
    Which is not running them from the command line. That's running them from within enigma2.
    MiracleBox Prem Twin HD - 2@DVB-T2 + Xtrend et8000 - 5(incl. 2 different USBs)@DVB-T2[terrestrial - UK Freeview HD, Sandy Heath] - LAN/USB-stick/HDD

  15. #13
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    Quote Originally Posted by birdman View Post
    Which is not running them from the command line. That's running them from within enigma2.
    Sorry im not sure what you mean how should I chmod 755? everything eles seems to work fine im going to try
    Code:
    import subprocess
    
    subprocess.call(['chmod', '0444', 'path'])

  16. #14
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    Ha Ha the above works I did see it before but I didnt think of using it as ive always used os. Thanks for the suggestions ive learned a lot about python in the last week its amazing the next step is trying to figure out how to add crontimer settings or learn how to do auto download

    Just a thought would I still use if os exist or would I use another method?
    Last edited by dsayers; 25-09-16 at 23:01.

  17. #15
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    another question does that mean scriptrunner.py is wrong as well? thats where i got os.chmod from

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.