Commits

Miki Tebeka committed ccef10c

mkdir and opts not needed

Comments (0)

Files changed (2)

 # conn.chown('/tmp/z8', 'cloudera')
 # print('open')
 # print(conn.read('/tmp/z8').decode('utf-8'))
-remote = '/tmp/z138'
+# remote = '/tmp/z138'
 # print('put')
 # conn.put('README.rst', remote, overwrite=True)
-print('append')
-conn.append(__file__, remote)
+# print('append')
+# conn.append(__file__, remote)
+print('mkdir')
+print(conn.mkdir('/tmp/zolo'))

webhdfs/__init__.py

             query['buffersize'] = intparam(buffersize)
         self._put('APPEND', 'POST', local, path, query)
 
+    @jsonpath(['boolean'])
+    def mkdir(self, path, permission=0):
+        query = {}
+        if permission:
+            query = {'permission': octperm(permission)}
 
+        return self._op('PUT', path, 'MKDIRS', query)
+
+    # Below here are some utility functions
     def _put(self, op, method, local, path, query):
         if not isfile(local):
             raise WebHDFSError('put error: {} not found'.format(local))
             raise WebHDFSError(resp.reason)
         return resp
 
-    def _op(self, method, path, op, query=None, opts=None):
-        opts = opts or {}
-
+    def _op(self, method, path, op, query=None):
         url = '{}{}?op={}'.format(self.base_url, path, op)
 
         if self.user:
         if query:
             url += '&{}'.format(urlencode(query))
 
-        resp = requests.request(method, url, allow_redirects=False, **opts)
+        resp = requests.request(method, url, allow_redirects=False)
         return self._check_resp(resp)
 
     def _gen_base(self, host, port):