[Update] 修改permisstion util

This commit is contained in:
ibuler
2018-06-01 16:22:52 +08:00
parent e7c7c3a7a8
commit 482d1bb27f
5 changed files with 26 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ import calendar
import threading
from io import StringIO
import uuid
from functools import wraps
import paramiko
import sshpubkeys
@@ -395,3 +396,17 @@ class TeeObj:
def close(self):
self.file_obj.close()
def with_cache(func):
cache = {}
key = "_{}.{}".format(func.__module__, func.__name__)
@wraps(func)
def wrapper(*args, **kwargs):
cached = cache.get(key)
if cached:
return cached
res = func(*args, **kwargs)
cache[key] = res
return res
return wrapper