|
From: <di...@us...> - 2013-01-02 19:48:28
|
Revision: 837
http://safekeep.svn.sourceforge.net/safekeep/?rev=837&view=rev
Author: dimi
Date: 2013-01-02 19:48:22 +0000 (Wed, 02 Jan 2013)
Log Message:
-----------
Add flexible capability test
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-02 19:31:12 UTC (rev 836)
+++ safekeep/trunk/safekeep 2013-01-02 19:48:22 UTC (rev 837)
@@ -1418,15 +1418,35 @@
if ret:
warn('Failed to cleanup old data, please fix the problem manually')
+def get_protocol_info(protocol, is_client):
+ (major_s, minor_s) = protocol.strip().split('.')
+ major = int(major_s)
+ minor = int(minor_s)
+
+ caps = []
+ if major == 1:
+ if minor >= 3:
+ caps.append('DEFAULT')
+
+ return {
+ 'version': (major, minor),
+ 'caps': caps
+ }
+
+
def do_server_compat(client_versions):
(client_protocol, client_version) = client_versions.split(',')
- (client_major, client_minor) = client_protocol.strip().split('.')
+ compat = {
+ 'client': get_protocol_info(client_protocol, True),
+ 'server': get_protocol_info(PROTOCOL, False)
+ }
+
(server_major, server_minor) = PROTOCOL.split('.')
- if server_major != client_major:
+ if compat['server']['version'][0] != compat['client']['version'][0]:
raise Exception('Incompatible protocols: %s <> %s' % (PROTOCOL, client_protocol))
- elif int(server_minor) > int(client_minor):
+ elif compat['server']['version'][1] > compat['client']['version'][1]:
info('Protocol mismatch, but compatible: %s <> %s' % (PROTOCOL, client_protocol))
- return (int(server_minor) - int(client_minor))
+ return compat
def do_server(cfgs, ids, nice, ionice, force, cleanup):
global statistics, client_defaults
@@ -1481,7 +1501,7 @@
compat = do_server_compat(client_versions)
# This test will need to be improved for later PROTOCOL versions.
- if compat <= 0 and len(client_defaults):
+ if ('DEFAULT' in compat['client']['caps']) and len(client_defaults):
cin.write('DEFAULT: %s\n' % (','.join(client_defaults)))
cin.flush()
do_server_getanswer(cout)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|