Does HTTP web server in kodi system the same of SimpleHTTPServer ?
#31
(2018-09-24, 20:25)Spiderfish Wrote: So what is the best solution to use apache server? can I make it with user/password ?
... you still haven't made it clear what problem you're trying to solve, here. 

It sounds like sharing files between two systems, but I still haven't seen a clear description of what your desirable outcome is as yet.
Reply
#32
I'm still not completely sure what you are trying to achieve here.  If its just to up/download stuff to libreelec, if you 'Enable SAMBA' in the libreelec settings, you can use a filebrowser to access all the shares.

Image

Like that.  Gives you access to all the stuff you probably need.  You can also turn on password protected access for it.
Learning Linux the hard way !!
Reply
#33
I want to use it because I want one kodi box to access remote python file through http server!
Reply
#34

  1. Does it need to be via the http server?
  2. When you say "access", do you want one machine to run the python script on the other?
  3. If this is your requirement... why was MySQL needed?
Reply
#35
I made it like this :

import requests

r = requests.get("http://192.168.1.200:4080/storage/.kodi/addons/test2.py")

So thats why I need http server!
Reply
#36
Why don't you use xbmcvfs and Samba ?  Samba is already built into libreelec, you just need to turn it on (although it doesn't by default share the addon directory, which is a _good_ thing as you should be storing stuff in addon_data). Then you can copy the file with something like
Code:
import subprocess
import xbmcvfs
result = xbmcvfs.copy('smb://192.168.1.200/userdata/addon_data/my_addon/test2.py', '/home/username/.kodi/userdata/addon_data/my_addon/test2.py')
print result
subprocess.call(["python", "/home/username/.kodi/userdata/addon_data/my_addon/test2.py"])

Absolutely no need for a web server for such a trivial task.  That copies it, prints true or false for whether it worked or not and then runs it.
Learning Linux the hard way !!
Reply
#37
@black_eagle 

Thanks for suggestion I will try it for sure..!
Reply
#38
(2018-09-26, 12:45)Spiderfish Wrote: @black_eagle 

Thanks for suggestion I will try it for sure..!
 No problem.

The best way to solve your issues are to explain in detail _what_ you want to happen and _how_ you are trying to achieve it.  Then other people can look at that and help you find the best method to do it.  Installing a full LAMP stack to copy one file for instance is more than overkill.  The simpler you can make things the better, as there is less to go wrong, and if something _does_ go wrong, it's much easier to find out why.  Utilising stuff that is either already built into your OS or into Kodi is a much better solution than installing a bunch of other stuff that you don't likely need.

You could also do it by editing /etc/fstab on the target machine to automount the samba share from the remote machine as a local directory.  You could then copy the file with a simple 'cp /mnt/samba_share/test2.py /path/to/copy/file/to/' .  Or you could automate that with a little shell script or python script and call it from cron or have it run when kodi starts (using autoexec.py).

There are lots of ways to achieve the same thing, but using a web server feels to me like using a car crusher to crack a nut open !!
Learning Linux the hard way !!
Reply
#39
@black_eagle 

This is what I did in addon script.py

import requests





r = requests.get("http://192.168.1.200:4080/storage/.kodi/addons/test2.py")

code = r.text

with open("/Users/user/AppData/Roaming/Kodi/addons/script.activatewindowid/tmp.py", "w") as f:
   f.write(code)

test2 = __import__('tmp')

if test2.x == 101:
    xbmc.executebuiltin('ActivateWindow(1199)')
else:
    xbmc.executebuiltin('ActivateWindow(settings)')


what I want that remote kodi hardware need to click on button and activate two python scripts one is test.py which contain json-rpc to execute script.py in kodi pc as mention above, the second is test2.py which contain an x value to use it in Kodi pc with if function as mention above as well.

For that reason I used http server to let kodi in pc to read test2.py in remote kodi 192.168.1.200.

but in other way I will try your way as you suggested will be much safer as well.
Reply
#40
I did this :


import subprocess
import xbmcvfs

result = xbmcvfs.copy('smb://192.168.1.200/userdata/addon_data/test2.py', 'home/my widnows usename/userdata/addon_data/test2.py')

if result == 101:
    xbmc.executebuiltin('ActivateWindow(1199)')
else:
    xbmc.executebuiltin('ActivateWindow(settings)')

subprocess.call(["python", "/home/my windows username/kodi/userdata/addon_data/test2.py"])

----------------------------------------------
And got this error:

XFILE::CDirectory::Create - Error creating home/my windows username/userdata/addon_data
19:39:13.994 T:111820   ERROR: XFILE::CDirectory::Create - Error creating home/my windows username/userdata/addon_data\
Reply
#41
So many antipatterns condensed into such a small space...

Well, it looks like you got what you asked for.  Whether it's what you want or need is another matter.
Reply
#42
But I couldn't be able to copy test2.py to my destination!
Reply
#43
(2018-09-27, 18:25)Spiderfish Wrote: But I couldn't be able to copy test2.py to my destination!
 Because looking at what you have written, home/my widnows usename/ you appear to be trying to copy to a windows based machine, in which case you need to use a Windows style path for the target.  C:\path\to\target or something.

All this stuff is documented in either the wiki under Add-on_development (wiki) or in the Kodi documentation https://codedocs.xyz/xbmc/xbmc/index.html or http://mirrors.kodi.tv/docs/python-docs/14.x-helix/  .  That last one is a bit old but is still perfectly relevant.

Also, I feel that I should point out that in your code, result will contain either true or false depending on if the copy command completed successfully or not.  Therefore, testing for result == 101 is a fruitless exercise.  See http://mirrors.kodi.tv/docs/python-docs/...html#-copy as a starting reference.
Learning Linux the hard way !!
Reply
#44
I tired this way also didn't copied:


source = 'smb://kodi:[email protected]/userdata/addon_data/test2.py'
destination = 'C:\Users\myusername\AppData\Roaming\Kodi\userdata\addon_data\test.py'
success  = xbmcvfs.copy(source, destination)


no error getting in logs ...strange!
Reply
#45
it works now like this:


source = 'smb://kodi:[email protected]/userdata/addon_data/test2.py'
destination = 'special://home/userdata/addon_data/test.py'
success  = xbmcvfs.copy(source, destination)


thanks
Reply

Logout Mark Read Team Forum Stats Members Help
Does HTTP web server in kodi system the same of SimpleHTTPServer ?0