[RELEASE - BETA] service.datasync

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Bstrdsmkr Offline
Fan
Posts: 651
Joined: Oct 2010
Reputation: 12
Post: #11
(2012-04-03 20:47)DecK Wrote:  
  1. How, in python, do a inititiate a call to a remote instance of XBMC (identifed by a IP4 address) to return:
    1. the OS of the remote instance.
    2. the full path to the userdata folder on the remote machine



Again, not dismissing the pull approach, just trying to see if I can get the push to work first.
1. Adapted from http://www.voidspace.org.uk/python/artic...ib2.shtml:
PHP Code:
import urllib
import urllib2
username 
'user'
password 'pass'
host '192.168.1.1'
port '9090'
url 'http://%s:%s@%s:%s/jsonrpc' %(usernamepasshostport)
user_agent 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
values = {"jsonrpc""2.0""method""AudioPlayer.PlayPause""id""1"}
headers = { 'User-Agent' user_agent }

data urllib.urlencode(values)
req urllib2.Request(urldataheaders)
response urllib2.urlopen(req)
the_page response.read() 

I'm doing this on the fly and about to leave, but that should get you started, you can set any necessary headers in the headers dict change the JSON string in values as needed. Reference http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4 to see what you need to change "values" to to get the desired result
find quote
robweber Online
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #12
Here is a post with a python class for sending a json command via http to another xbmc instance:

http://forum.xbmc.org/showthread.php?tid...#pid678603
find quote
Bstrdsmkr Offline
Fan
Posts: 651
Joined: Oct 2010
Reputation: 12
Post: #13
Also, the userdata folder on the remote machine will always be special://userdata

Not sure you can get the OS, so you may have to configure it in settings. I think the easy approach is to feed your service the general information and let it figure things out locally.
find quote
DecK Offline
Senior Member
Posts: 134
Joined: Nov 2008
Reputation: 4
Location: Round Rock, TX
Post: #14
Thank you both. Guess I won't be getting any sleep tonight....
find quote
robweber Online
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #15
Just checking back to see if you've made any progress on this? I'm watching your github repo and have seen a few commits.
find quote
DecK Offline
Senior Member
Posts: 134
Joined: Nov 2008
Reputation: 4
Location: Round Rock, TX
Post: #16
I've done some work on the JSON interface, but have hit a roadblock in the Files.GetDirectory method. I am not able to see the last modified timestamp on a file, which is a key requirement for incremental syncing.

In the mean time I've been playing around with the ftplib as a possible alternative for gettting the file. That's working (not yet committed, will do so tonight) but I think I will to extentd it to use SFTP (SSH) before I go beta. I don't wnat users to have to be running an FTP server, unless I can't get anything else to work.
find quote
robweber Online
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #17
Awesome. Glad to know you're still working on this idea.

I agree that having users configure an outside service is kind of a pain - keeping everything within the addon (and xbmc) as much as possible will really make it useful. There would be countless ways (rsync, scripts, etc) to do this using just the OS, having it as a pure xbmc addon with no outside configuration would be ideal.
find quote
Bstrdsmkr Offline
Fan
Posts: 651
Joined: Oct 2010
Reputation: 12
Post: #18
This is a W.A.G., but look into using the vfs interface. Something like http://192.168.1.2:8080/vfs/special://home/xbmc.log

I'm doing this from memory so that address might not be 100%, but I think that should give you the log file via http. Maybe you get lucky and can get the file details from one of the headers?

Alternatively, I think you could write a quick python script to be stored in the addon's folder. The script creates a file with a rolling list of files that have changed. Your client side addon calls the script (to make sure the list is up to date), downloads this file, determines which files it needs, then grabs them.

Hope that points you in the right direction!
find quote
DecK Offline
Senior Member
Posts: 134
Joined: Nov 2008
Reputation: 4
Location: Round Rock, TX
Post: #19
(2012-04-18 23:32)Bstrdsmkr Wrote:  Alternatively, I think you could write a quick python script to be stored in the addon's folder. The script creates a file with a rolling list of files that have changed. Your client side addon calls the script (to make sure the list is up to date), downloads this file, determines which files it needs, then grabs them.

Great idea! I already have a setting for Server (the box to pull from) versus Client (the box doing the pull). I can add this script and run it only on the server side and make it available to all the clients for the compare.
find quote
DecK Offline
Senior Member
Posts: 134
Joined: Nov 2008
Reputation: 4
Location: Round Rock, TX
Post: #20
All
I've updated the first post to reflect that fact that I am now in Beta. Testers would be greatly appreciated at this point.


Cheers
Declan
find quote
Post Reply