Пример #1
0
	def on_any_event(self, event):
		logging.debug('auto sync directory event triggered')
		time.sleep(0.1)  #ignore any transient changes
		
		my_rpc_id = random.randint(1,1000000) #TODO: rpc_id collisions could occur
		sib.cmd(method_name='commit', params=[self.key, self.monitoring_directory, self.share_ID, self.user_name, 'auto', None, None], to=('localhost', self.command_port), rpc_id = my_rpc_id)
		while my_rpc_id not in self.json_response_dict:
			time.sleep(0.1)
		commit_packet = self.json_response_dict[my_rpc_id]
		commit_hash = commit_packet.json_RPC_object['result']
		
		sib.cmd(method_name='push_update_to_peer', params=[self.share_ID, None, commit_hash], to=('localhost', self.command_port))
		time.sleep(4)  #@TODO:  wait until pushing updates is complete, then run next command
Пример #2
0
    def on_any_event(self, event):
        logging.debug('auto sync directory event triggered')
        time.sleep(0.1)  #ignore any transient changes

        my_rpc_id = random.randint(
            1, 1000000)  #TODO: rpc_id collisions could occur
        sib.cmd(method_name='commit',
                params=[
                    self.key, self.monitoring_directory, self.share_ID,
                    self.user_name, 'auto', None, None
                ],
                to=('localhost', self.command_port),
                rpc_id=my_rpc_id)
        while my_rpc_id not in self.json_response_dict:
            time.sleep(0.1)
        commit_packet = self.json_response_dict[my_rpc_id]
        commit_hash = commit_packet.json_RPC_object['result']

        sib.cmd(method_name='push_update_to_peer',
                params=[self.share_ID, None, commit_hash],
                to=('localhost', self.command_port))
        time.sleep(
            4
        )  #@TODO:  wait until pushing updates is complete, then run next command
Пример #3
0
sib_b.js.storage_directory = peer_B_storage
sib_b.js.my_machine_ID = 'machine_B'

sib_a = SIB()
sib_a.new_sockets.put(11121)
sib_a.js.storage_directory = peer_A_storage
sib_a.js.my_machine_ID = 'machine_A'

#TODO: this transfer is slow?

sib_b.run_forever()
sib_a.run_forever()
time.sleep(0.5)

sib.cmd(method_name='update_machine_address',
        params=['machine_B', 'localhost', 11120],
        to=('localhost', 11121))
sib.cmd(method_name='update_machine_address',
        params=['machine_A', 'localhost', 11121],
        to=('localhost', 11120))
time.sleep(0.5)

sib.cmd(method_name='get_file',
        params=['machine_A', 'test_share', large_file_hash],
        to=('localhost', 11120),
        frm=11121)

time.sleep(5)
sib_b.terminate()
sib_a.terminate()
Пример #4
0
sib_b.new_sockets.put(11120)
sib_b.js.storage_directory = peer_B_storage
sib_b.js.my_machine_ID = 'machine_B'

sib_a = SIB()
sib_a.new_sockets.put(11121)
sib_a.js.storage_directory = peer_A_storage
sib_a.js.my_machine_ID = 'machine_A'

#TODO: this transfer is slow?

sib_b.run_forever()
sib_a.run_forever()
time.sleep(0.5)

sib.cmd(method_name='update_machine_address', params=['machine_B','localhost',11120], to=('localhost',11121))
sib.cmd(method_name='update_machine_address', params=['machine_A','localhost',11121], to=('localhost',11120))
time.sleep(0.5)

sib.cmd(method_name='get_file', params=['machine_A', 'test_share', large_file_hash], to=('localhost',11120), frm=11121)

time.sleep(5)
sib_b.terminate()
sib_a.terminate()