Commits

Miki Tebeka committed c2e5e8d

rename

Comments (0)

Files changed (2)

 from webhdfs import WebHDFS
 
 conn = WebHDFS('192.168.1.121', user='hdfs')
+remote = '/tmp/z138'
 # print('listdir')
 # print(conn.listdir('/tmp'))
 # print('stat')
-# print(conn.stat('/tmp/z8'))
+# print(conn.stat(remote))
 # print('checksum')
-# print(conn.checksum('/tmp/z8'))
+# print(conn.checksum(remote))
 # print('home')
 # print(conn.home())
 # print('chmod')
-# conn.chmod('/tmp/z8', 0o777)
+# conn.chmod(remote, 0o777)
 # print('chown')
-# conn.chown('/tmp/z8', 'cloudera')
+# conn.chown(remote, 'cloudera')
 # print('open')
-# print(conn.read('/tmp/z8').decode('utf-8'))
-# remote = '/tmp/z138'
+# print(conn.read(remote).decode('utf-8'))
 # print('put')
 # conn.put('README.rst', remote, overwrite=True)
 # print('append')
 # conn.append(__file__, remote)
-print('mkdir')
-print(conn.mkdir('/tmp/zolo'))
+# print('mkdir')
+# print(conn.mkdir('/tmp/zolo'))
+print('rename')
+print(conn.rename(remote, '/tmp/8z'))

webhdfs/__init__.py

 
         return self._op('PUT', path, 'MKDIRS', query)
 
+    @jsonpath(['boolean'])
+    def rename(self, path, to):
+        query = {'destination': to}
+        return self._op('PUT', path, 'RENAME', query)
+
     # Below here are some utility functions
     def _put(self, op, method, local, path, query):
         if not isfile(local):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.