mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-23 09:20:20 +08:00
model
This commit is contained in:
parent
8ef47c6669
commit
f660e5dbef
Binary file not shown.
30
cli/model.py
30
cli/model.py
@ -31,7 +31,7 @@ class GitOp:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def gitClone(cmd: str):
|
def gitClone(self, cmd: str):
|
||||||
'''git clone'''
|
'''git clone'''
|
||||||
try:
|
try:
|
||||||
print("Command is: "+cmd)
|
print("Command is: "+cmd)
|
||||||
@ -46,12 +46,28 @@ class FileOp:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def printJson(path: str):
|
def printJson(self, path: str):
|
||||||
|
'''output file content'''
|
||||||
|
|
||||||
with open(path,newline='') as file:
|
with open(path,newline='') as file:
|
||||||
print(file.read())
|
print(file.read())
|
||||||
|
|
||||||
def convertToJson(path: str):
|
def fileToJson(self, path: str, remark: Optional[str] = "#", separate: Optional[str] = "="):
|
||||||
pass
|
''' convert file to Json '''
|
||||||
|
|
||||||
|
dict = {}
|
||||||
|
with open(path) as fh:
|
||||||
|
for line in fh:
|
||||||
|
|
||||||
|
print(line.find(remark))
|
||||||
|
if line.find(remark) != 0:
|
||||||
|
item, value = line.strip().split(separate, -1)
|
||||||
|
item = line.strip()
|
||||||
|
dict[item] = value
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
fh.close()
|
||||||
|
print (dict)
|
||||||
|
|
||||||
|
|
||||||
class NetOp:
|
class NetOp:
|
||||||
@ -85,7 +101,7 @@ class SecurityOp:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def randomPass(self, length: Optional[int] = 16):
|
def randomPass(self, length: Optional[int] = 16):
|
||||||
'''set password'''
|
'''set strong password'''
|
||||||
|
|
||||||
alphabet = string.ascii_letters + string.digits
|
alphabet = string.ascii_letters + string.digits
|
||||||
while True:
|
while True:
|
||||||
@ -97,6 +113,6 @@ class SecurityOp:
|
|||||||
print(password)
|
print(password)
|
||||||
|
|
||||||
|
|
||||||
test=SecurityOp()
|
test=FileOp()
|
||||||
#test.setPort(9001)
|
#test.setPort(9001)
|
||||||
test.randomPass(25)
|
test.fileToJson('./joomla/.env_all')
|
Loading…
Reference in New Issue
Block a user