diff options
author | Alice Ferrazzi <alicef@gentoo.org> | 2017-06-17 08:25:58 +0900 |
---|---|---|
committer | Alice Ferrazzi <alicef@gentoo.org> | 2017-06-17 08:25:58 +0900 |
commit | 7a33b16fc362d3b42037011f1a8af9c0f1afc3c1 (patch) | |
tree | a3ac2ef43035d54283ec114982e517aefee7610c /elivepatch_client/client/restful.py | |
parent | added elivepatch server url option to argparse (diff) | |
download | elivepatch-7a33b16fc362d3b42037011f1a8af9c0f1afc3c1.tar.gz elivepatch-7a33b16fc362d3b42037011f1a8af9c0f1afc3c1.tar.bz2 elivepatch-7a33b16fc362d3b42037011f1a8af9c0f1afc3c1.zip |
add restful client communication and url option to argparse
Diffstat (limited to 'elivepatch_client/client/restful.py')
-rw-r--r-- | elivepatch_client/client/restful.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py new file mode 100644 index 0000000..b5cf5e6 --- /dev/null +++ b/elivepatch_client/client/restful.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import json +import urllib2 +import requests + +class ManaGer(object): + def __init__(self,server_url): + self.server_url = server_url + + def version(self): + version = json.load(urllib2.urlopen(self.server_url)) + print(version) + + def send_config(self, config_path, config_file): + url = self.server_url + headers = {'elivepatch': 'password'} + files = {'file': (config_file, open(config_path, 'rb'), 'multipart/form-data', {'Expires': '0'})} + r = requests.post(url, files=files, headers=headers) + |