forked from Louis-me/appiumn_auto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasePickle.py
36 lines (31 loc) · 903 Bytes
/
basePickle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
__author__ = "shikun"
import pickle
import os
from common import operateFile
from common.variable import GetVariable
def write_pickle(dict_data, path="data.pickle"):
read = read_pickle(path)
result = []
if len(read) > 0:
read.append(dict_data)
result = read
else:
result.append(dict_data)
with open(path, 'wb') as f:
print(result)
pickle.dump(result, f, 0)
def read_pickle(path):
data = {}
if operateFile.OperateFile(path).check_file():
with open(path, 'rb') as f:
try:
data = pickle.load(f)
except EOFError:
pass
print(data)
return data
if __name__=="__main__":
data = {"log":"132"}
write_pickle(data, path=GetVariable.CRASH_LOG_PATH)
read_pickle(path=GetVariable.CRASH_LOG_PATH)
# operateFile.OperateFile(PATH("data.pickle")).remove_file()