From 3747521543fbfd5dec854c1796f984da5c61687b Mon Sep 17 00:00:00 2001 From: zhanghb Date: Mon, 28 May 2018 20:37:33 +0800 Subject: [PATCH] edit folder language --- del_secret_header/del_secret_header.py | 110 ------------------ .../download_file_with_iter.py" | 0 .../README.MD" | 0 .../list_file.py" | 0 .../README.MD" | 0 .../delete_file.py" | 0 .../purges.py" | 0 .../README.md" | 0 .../delete_file.php" | 0 .../README.MD" | 0 .../count_directory_size.py" | 0 11 files changed, 110 deletions(-) delete mode 100644 del_secret_header/del_secret_header.py rename download_file/download_file_with_iter.py => "\344\270\213\350\275\275\345\244\207\344\273\275\346\214\207\345\256\232\347\233\256\345\275\225\346\226\207\344\273\266\350\204\232\346\234\254--Python2.7/download_file_with_iter.py" (100%) rename list_file/README.MD => "\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" (100%) rename list_file/list_file.py => "\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/list_file.py" (100%) rename delete_file/README.MD => "\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" (100%) rename delete_file/delete_file.py => "\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/delete_file.py" (100%) rename purges/purges.py => "\346\214\207\345\256\232\347\233\256\345\275\225\347\274\223\345\255\230\345\210\267\346\226\260--Python2.7/purges.py" (100%) rename delete_local_file/README.md => "\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/README.md" (100%) rename delete_local_file/delete_file.php => "\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/delete_file.php" (100%) rename count_directory_size/README.MD => "\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/README.MD" (100%) rename count_directory_size/count_directory_size.py => "\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/count_directory_size.py" (100%) diff --git a/del_secret_header/del_secret_header.py b/del_secret_header/del_secret_header.py deleted file mode 100644 index d4cd459..0000000 --- a/del_secret_header/del_secret_header.py +++ /dev/null @@ -1,110 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -from base64 import b64encode -import requests -import urllib -import Queue -import getpass - -# ----------------------- -bucket = raw_input("Please enter your serverName:") -username = raw_input("Please enter your userName:") -password = getpass.getpass("Plaser enter your Password:") -# ----------------------- - -queue = Queue.LifoQueue() -count = 0 - - -def do_http_request(method, key, upyun_iter): - uri = '/' + bucket + (lambda x: x[0] == '/' and x or '/' + x)(key) - if isinstance(uri, unicode): - uri = uri.encode('utf-8') - uri = urllib.quote(uri) - headers = {} - headers['Authorization'] = "Basic " + b64encode(username + ':' + password) - headers['X-Upyun-Meta-Secret'] = "true" - headers['User-Agent'] = "uptechs" - headers['X-List-Limit'] = '300' - if upyun_iter is not None or upyun_iter is not 'g2gCZAAEbmV4dGQAA2VvZg': - headers['x-list-iter'] = upyun_iter - - url = "http://v0.api.upyun.com" + uri - requests.adapters.DEFAULT_RETRIES = 5 - session = requests.session() - try: - response = session.request(method, url, headers=headers, timeout=30) - status = response.status_code - if status == 200: - content = response.content - try: - iter_header = response.headers['x-upyun-list-iter'] - except Exception as e: - iter_header = 'g2gCZAAEbmV4dGQAA2VvZg' - return content + "`" + str(iter_header) - else: - print 'status: ' + str(status) + '--->' + url - print 'message: ' + str(response.headers['X-Error-Code']) - return None - except Exception as e: - pass - - -def getlist(key, upyun_iter): - content = do_http_request('GET', key, upyun_iter) - if not content: - return None - content = content.split("`") - items = content[0].split('\n') - content = [dict(zip(['name', 'type', 'size', 'time'], - x.split('\t'))) for x in items] + content[1].split() - return content - - -def print_file_with_iter(path): - upyun_iter = None - while True: - while upyun_iter != 'g2gCZAAEbmV4dGQAA2VvZg': - res = getlist(path, upyun_iter) - if res: - upyun_iter = res[-1] - for i in res[:-1]: - try: - if not i['name']: - continue - new_path = path + i['name'] if path == '/' else path + '/' + i['name'] - patch_uri = "http://v0.api.upyun.com/"+bucket+new_path+"?metadata=delete" - if i['type'] == 'F': - queue.put(new_path) - elif i['type'] == 'N': - print patch_uri - headers = {} - headers['Authorization'] = "Basic " + b64encode(username + ':' + password) - headers['X-Upyun-Meta-Secret'] = "true" - r = requests.patch(patch_uri,headers=headers) - r.status_code - print r - with open(bucket + '_file.txt', 'a') as f: - f.write(new_path + '\n') - except Exception as e: - print e - else: - if not queue.empty(): - path = queue.get() - upyun_iter = None - queue.task_done() - else: - break - - -if __name__ == '__main__': - if len(str.strip(bucket))==0 or len(str.strip(username))==0 or len(str.strip(password))==0: - print "401 buket or username and password is null" - else: - path = raw_input('input a path( e.g: "/" ) : ') - while len(path)==0: - path = raw_input('input a path( e.g: "/" ) : ') - print_file_with_iter(path) - - print "Job's Done!" diff --git a/download_file/download_file_with_iter.py "b/\344\270\213\350\275\275\345\244\207\344\273\275\346\214\207\345\256\232\347\233\256\345\275\225\346\226\207\344\273\266\350\204\232\346\234\254--Python2.7/download_file_with_iter.py" similarity index 100% rename from download_file/download_file_with_iter.py rename to "\344\270\213\350\275\275\345\244\207\344\273\275\346\214\207\345\256\232\347\233\256\345\275\225\346\226\207\344\273\266\350\204\232\346\234\254--Python2.7/download_file_with_iter.py" diff --git a/list_file/README.MD "b/\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" similarity index 100% rename from list_file/README.MD rename to "\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" diff --git a/list_file/list_file.py "b/\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/list_file.py" similarity index 100% rename from list_file/list_file.py rename to "\345\210\227\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/list_file.py" diff --git a/delete_file/README.MD "b/\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" similarity index 100% rename from delete_file/README.MD rename to "\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/README.MD" diff --git a/delete_file/delete_file.py "b/\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/delete_file.py" similarity index 100% rename from delete_file/delete_file.py rename to "\345\210\240\351\231\244\346\214\207\345\256\232\347\233\256\345\275\225\344\270\213\347\232\204\346\226\207\344\273\266--Python2.7/delete_file.py" diff --git a/purges/purges.py "b/\346\214\207\345\256\232\347\233\256\345\275\225\347\274\223\345\255\230\345\210\267\346\226\260--Python2.7/purges.py" similarity index 100% rename from purges/purges.py rename to "\346\214\207\345\256\232\347\233\256\345\275\225\347\274\223\345\255\230\345\210\267\346\226\260--Python2.7/purges.py" diff --git a/delete_local_file/README.md "b/\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/README.md" similarity index 100% rename from delete_local_file/README.md rename to "\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/README.md" diff --git a/delete_local_file/delete_file.php "b/\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/delete_file.php" similarity index 100% rename from delete_local_file/delete_file.php rename to "\346\214\211\346\234\254\345\234\260\346\226\207\344\273\266\345\210\227\350\241\250\345\210\240\351\231\244\346\226\207\344\273\266--PHP/delete_file.php" diff --git a/count_directory_size/README.MD "b/\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/README.MD" similarity index 100% rename from count_directory_size/README.MD rename to "\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/README.MD" diff --git a/count_directory_size/count_directory_size.py "b/\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/count_directory_size.py" similarity index 100% rename from count_directory_size/count_directory_size.py rename to "\347\273\237\350\256\241\346\214\207\345\256\232\347\233\256\345\275\225\345\244\247\345\260\217--Python2.7/count_directory_size.py"