Thanks, I need it also to windows.
In addition, Can you write here more about your process on linux?
Thanks

בתאריך יום שני, 15 בספטמבר 2014 10:30:59 UTC+3, מאת M S Vishwanath Bhat:
>
>
>
> On 15 September 2014 12:56, Yehonatan Arad <[email protected] <javascript:>
> > wrote:
>
>> Hi,
>> I want to run this service on the boot computer.
>> I think to run it on service, but I have a problems on it.
>> Do you have idea?
>>
> I had the same requirement. This is what I did.
>
>
> (works only on Linux systems)
>
> I modified the service to run as a daemon (like a service in linux). Wrote 
> a init script inside and /etc/init.d And then added the service to 
> chkconfig to start at boot time.
>
> Best Regards,
> Vishwanath
>
>
> Thanks,
>> Yehonatan
>>
>>
>> בתאריך יום רביעי, 10 בספטמבר 2014 12:28:39 UTC+3, מאת Yehonatan Arad:
>>
>>> I succeed:
>>>
>>> *on the server:*
>>> import rpyc
>>> from rpyc.utils.server import ThreadedServer, ForkingServer, 
>>> OneShotServer
>>>
>>> class DpaServerService(rpyc.Service): 
>>> def exposed_open(self, filename):
>>> return open(filename, "r")
>>>
>>> if __name__ == '__main__':
>>> server = ThreadedServer(DpaServerService, port = 12345)
>>> server.start()
>>>
>>>
>>> *and on the client:*
>>> c = rpyc.connect("IP","PORT")
>>> remote= c.root.open("File")
>>> local = open("File","w")
>>> shutil.copyfileobj(remote, local)
>>> remote.close()
>>> local.close() 
>>>
>>>
>>>
>>>
>>> בתאריך יום רביעי, 10 בספטמבר 2014 09:38:33 UTC+3, מאת Yehonatan Arad:
>>>>
>>>> Thanks very much. I success now to copy the file, on classic mode.
>>>> Now i want to change the method to service mode. (because security 
>>>> issues).
>>>> What I need to do for this?
>>>>
>>>> On server I ran this file:
>>>> class DoStuffService(rpyc.Service):
>>>>    def on_connect(self):
>>>>        "Do some things when a connection is made"
>>>>    def on_disconnect(self):
>>>>        "Do some things AFTER a connection is dropped"
>>>>    def exposed_func1(self, *args, **kws):
>>>>        "Do something useful and maybe return a value"
>>>>    def exposed_func2(self, *args, **kws):
>>>>        "Like func1, but do something different"
>>>>
>>>> if __name__ == '__main__':
>>>>    rpyc.utils.server.ThreadedServer(DoStuffService).start()
>>>>
>>>> On client I tried to connect such:
>>>> c = rpyc.connect(IP,PORT,service = "DoStuffService")
>>>>
>>>> I get this error, why it can be?
>>>> Traceback (most recent call last):
>>>>   File "<stdin>", line 1, in <module>
>>>>   File "C:\Python26\lib\site-packages\rpyc\utils\factory.py", line 89, 
>>>> in connect
>>>>     s = SocketStream.connect(host, port, ipv6 = ipv6, keepalive = 
>>>> keepalive)
>>>>   File "C:\Python26\lib\site-packages\rpyc\core\stream.py", line 132, 
>>>> in connect
>>>>     return cls(cls._connect(host, port, **kwargs))
>>>>   File "C:\Python26\lib\site-packages\rpyc\core\stream.py", line 102, 
>>>> in _connect
>>>>     s.connect(sockaddr)
>>>>   File "<string>", line 1, in connect
>>>> socket.error: [Errno 10061] No connection could be made because the 
>>>> target machine actively refused it
>>>>
>>>>
>>>> בתאריך יום רביעי, 10 בספטמבר 2014 08:02:07 UTC+3, מאת Tomer Filiba:
>>>>>
>>>>> Use c.builtin.open (or builtins, can't remember), not c.root.open
>>>>> On Sep 10, 2014 1:05 AM, "Yehonatan Arad" <[email protected]> wrote:
>>>>>
>>>>>> Hi Tomer,
>>>>>> I want to get file from server to the client.
>>>>>> I configured the open function on the rpyc_classic.py but I didn't 
>>>>>> success to call it from the other computer.
>>>>>> I got this error:
>>>>>> Can you help me?
>>>>>> Thanks
>>>>>>
>>>>>> >>> remote = c.root.open("FILE")
>>>>>> Traceback (most recent call last):
>>>>>>   File "<stdin>", line 1, in <module>
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\netref.py", line 
>>>>>> 150, in __getattr__
>>>>>>     return syncreq(self, consts.HANDLE_GETATTR, name)
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\netref.py", line 71, 
>>>>>> in syncreq
>>>>>>     return conn.sync_request(handler, oid, *args)
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\protocol.py", line 
>>>>>> 441, in sync_request
>>>>>>     raise obj
>>>>>> AttributeError: 'SlaveService' object has no attribute 'exposed_open'
>>>>>>
>>>>>> ========= Remote Traceback (1) =========
>>>>>> Traceback (most recent call last):
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\protocol.py", line 
>>>>>> 305, in _dispatch_request
>>>>>>     res = self._HANDLERS[handler](self, *args)
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\protocol.py", line 
>>>>>> 541, in _handle_getattr
>>>>>>     return self._access_attr(oid, name, (), "_rpyc_getattr", 
>>>>>> "allow_getattr", getattr)
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\protocol.py", line 
>>>>>> 507, in _access_attr
>>>>>>     return accessor(obj, name, *args)
>>>>>>   File "C:\Python26\lib\site-packages\rpyc\core\service.py", line 
>>>>>> 69, in _rpyc_getattr
>>>>>>     return getattr(self, name)
>>>>>> AttributeError: 'SlaveService' object has no attribute 'exposed_open'
>>>>>> "
>>>>>>
>>>>>> בתאריך יום שלישי, 17 בפברואר 2009 14:52:05 UTC+2, מאת Tomer Filiba:
>>>>>>>
>>>>>>> nice, but you might want to check out rpyc/utils/classic.py -- it 
>>>>>>> already has file transfer functionality :)
>>>>>>> it does require the classic mode, but assuming you can get a remote 
>>>>>>> file object,
>>>>>>> you can just use shutil.copyfileobj (you should check out shutil, 
>>>>>>> btw, if you're new to python)
>>>>>>>
>>>>>>> i.e.
>>>>>>>
>>>>>>> # == server ==
>>>>>>> class FileService(rpyc.Service):
>>>>>>>     def exposed_open(self, filename, mode = "r"):
>>>>>>>         return open(filename, mode)
>>>>>>>
>>>>>>> # == client ==
>>>>>>> c = rpyc.connect(host, port)
>>>>>>>
>>>>>>> # copy to client
>>>>>>> remote = c.root.open("/foo/bar")
>>>>>>> local = open("/tmp/foo/bar", "w")
>>>>>>> shutil.copyfileobj(remote, local)
>>>>>>>
>>>>>>> # copy to server
>>>>>>> local = open("/spam/bacon")
>>>>>>> remote = c.root.open("/tmp/spam/bacon", "w")
>>>>>>> shutil.copyfileobj(local, remote)
>>>>>>>
>>>>>>>
>>>>>>> hope it helps,
>>>>>>> -tomer
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Feb 17, 2009 at 14:30, CinnamonDonkey <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> No worries! I worked it out :)
>>>>>>>>
>>>>>>>> SERVER SHOULD BE:
>>>>>>>>
>>>>>>>>  class MyService( rpyc.Service ):
>>>>>>>>    class exposed_FileTransfer(  ):
>>>>>>>>       def exposed_Open( self, filename ):
>>>>>>>>         print "FILE TRANSFER OPEN FUNCTION CALLED - " + filename
>>>>>>>>        return 0
>>>>>>>>
>>>>>>>>  if __name__ == "__main__":
>>>>>>>>    s = ThreadedServer( MyService, port = 1234, reuse_addr = True )
>>>>>>>>    s.start()
>>>>>>>>
>>>>>>>>
>>>>>>>> CLIENT SHOULD BE:
>>>>>>>>
>>>>>>>>  if __name__ == "__main__":
>>>>>>>>    connection = rpyc.connect( options.serviceHostName,
>>>>>>>> options.servicePortNum )
>>>>>>>>     tf = connection.root.FileTransfer()
>>>>>>>>    tf.Open(  "SPANKING~!!!" )
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 17 Feb, 12:25, CinnamonDonkey <[email protected]>
>>>>>>>> wrote:
>>>>>>>> > I have written this on my server side:
>>>>>>>> >
>>>>>>>> >   class MyService( rpyc.Service ):
>>>>>>>> >     class exposed_FileTransfer(  ):
>>>>>>>> >       def exposed_Open( filename ):
>>>>>>>> >         print "FILE TRANSFER OPEN FUNCTION CALLED - " + filename
>>>>>>>> >         return 0
>>>>>>>> >
>>>>>>>> >   if __name__ == "__main__":
>>>>>>>> >     s = ThreadedServer( MyService, port = 1234, reuse_addr = True 
>>>>>>>> )
>>>>>>>> >     s.start()
>>>>>>>> >
>>>>>>>> > But on my client side I can't figure how to call it. I have tried:
>>>>>>>> >
>>>>>>>> >   if __name__ == "__main__":
>>>>>>>> >     connection = rpyc.connect( options.serviceHostName,
>>>>>>>> > options.servicePortNum )
>>>>>>>> >     connection.root.FileTransfer.Open( "SPANKING~!!!" )
>>>>>>>> >
>>>>>>>> > But I get the error:
>>>>>>>> >
>>>>>>>> >   TypeError: unbounded method expose_Open() must be called with
>>>>>>>> > exposed_FileTransfer instance as first argument.
>>>>>>>> >
>>>>>>>> > eh? I tried:
>>>>>>>> >
>>>>>>>> >   if __name__ == "__main__":
>>>>>>>> >     connection = rpyc.connect( options.serviceHostName,
>>>>>>>> > options.servicePortNum )
>>>>>>>> >     ft = connection.root.FileTransfer
>>>>>>>> >     ft.Open( "SPANKING~!!!" )
>>>>>>>> >
>>>>>>>> > and that does not work... I'm confussed.
>>>>>>>> >
>>>>>>>> > Please help.
>>>>>>>> >
>>>>>>>> > On 17 Feb, 09:17, CinnamonDonkey <[email protected]>
>>>>>>>> > wrote:
>>>>>>>> >
>>>>>>>> > > Thanx for the reply RedBaron.
>>>>>>>> >
>>>>>>>> > > I agree, I don't think it is the best way of doing a file 
>>>>>>>> transfer but
>>>>>>>> > > based on my limited knowledge of Python and RPyC I'd rather 
>>>>>>>> spend my
>>>>>>>> > > time learning a few systems well than lots of systems badly. At 
>>>>>>>> least
>>>>>>>> > > that is my theory at the moment, everything is subject to 
>>>>>>>> change ;-).
>>>>>>>> >
>>>>>>>> > > I do need, RPC for some genuine tasks later so I figured this 
>>>>>>>> would be
>>>>>>>> > > a good starting point as it satisfies two goals. How to 
>>>>>>>> transfer my
>>>>>>>> > > file and how to use RPyC :-D.
>>>>>>>> >
>>>>>>>> > > I have to say, I am very impressed with this Python'ing lark... 
>>>>>>>> Oh
>>>>>>>> > > what I have been missing all these years ;-).
>>>>>>>> >
>>>>>>>> > > On 17 Feb, 09:05, redbaron <[email protected]> wrote:
>>>>>>>> >
>>>>>>>> > > > Are you sure that RPyC is a good way to do it? I'm not sure 
>>>>>>>> but try to
>>>>>>>> > > > open file and then send file handler to remote service. As it 
>>>>>>>> said in
>>>>>>>> > > > docs all objects are passed by reference, so reading from 
>>>>>>>> that handler
>>>>>>>> > > > on remote side will actually make transfer from local machine 
>>>>>>>> to
>>>>>>>> > > > remote onee. I'm not sure will it work or not, but you could 
>>>>>>>> try it =)
>>>>>>>> >
>>>>>>>> > > > f = open(/path/to/file,"rb")
>>>>>>>> > > > ... send of on remote side
>>>>>>>> > > > ....do f.read() on remote side.
>>>>>>>> >
>>>>>>>> > > > be careful that f.read() will allocate memory equal to file 
>>>>>>>> size, if
>>>>>>>> > > > its really big then try to read it chunk by chunk like:
>>>>>>>> >
>>>>>>>> > > > g = open("/path/where/to/write","wb")
>>>>>>>> > > > chunk = f.read(1024*1024)
>>>>>>>> > > > while chunk:
>>>>>>>> > > >   g.write(chunk)
>>>>>>>> > > >   chunk = f.read(1024*1024)
>>>>>>>> >
>>>>>>>> >
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> An NCO and a Gentleman
>>>>>>>  
>>>>>>  -- 
>>>>>>
>>>>>> --- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "rpyc" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>  -- 
>>
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "rpyc" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/rpyc/91kMD-wy5vk/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to