Skip to content

Commit

Permalink
#2 #6 furture cleaning up the methods to create properties and channels
Browse files Browse the repository at this point in the history
  • Loading branch information
shroffk committed Dec 14, 2015
1 parent 1696b62 commit e3a2cba
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 92 deletions.
24 changes: 5 additions & 19 deletions channelfinder/ChannelFinderClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,11 @@ def __handleMultipleAddParameters(self, **kwds):
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth).raise_for_status()
elif 'property' in kwds and 'channelName' in kwds:
channels = [{u'name':kwds['channelName'].strip(), u'owner':self.__userName, u'properties':[kwds['property']]}]
self.__session.put(self.__baseURL + self.__propertiesResource + '/' + kwds['property'][u'name'], \
data=JSONEncoder().encode(self.__encodeProperty(kwds['property'], withChannels=channels)), \
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth).raise_for_status()
elif 'property' in kwds and 'channelNames' in kwds:
channels = []
for eachChannel in kwds['channelNames']:
channels.append({u'name':eachChannel, u'owner':self.__userName, u'properties':[kwds['property']]})
self.__session.put(self.__baseURL + self.__propertiesResource + '/' + kwds['property'][u'name'], \
data=JSONEncoder().encode(self.__encodeProperty(kwds['property'], withChannels=channels)), \
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth).raise_for_status()
elif 'property' in kwds and 'channels' in kwds:
data = kwds['property']
data['property']['channels'] = kwds['channels']
self.__session.put(self.__baseURL + self.__propertiesResource + '/' + kwds['property'][u'name'], \
data=JSONEncoder().encode(self.__encodeProperty(kwds['property'], withChannels=kwds['channels'])), \
data=JSONEncoder().encode(data), \
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth).raise_for_status()
Expand Down Expand Up @@ -524,15 +510,15 @@ def __handleSingleUpdateParameter(self, **kwds):
if 'channel' in kwds:
ch = kwds['channel']
r = self.__session.post(self.__baseURL + self.__channelsResource + '/' + ch[u'name'], \
data=JSONEncoder().encode(self.__encodeChannel(ch)), \
data=JSONEncoder().encode(ch), \
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth)
r.raise_for_status()
elif 'property' in kwds:
property = kwds['property']
r = self.__session.post(self.__baseURL + self.__propertiesResource + '/' + property[u'name'], \
data=JSONEncoder().encode(self.__encodeProperty(property)), \
data=JSONEncoder().encode(property), \
headers=copy(self.__jsonheader), \
verify=False, \
auth=self.__auth)
Expand Down
Loading

0 comments on commit e3a2cba

Please sign in to comment.