some changes, starting wp setup
This commit is contained in:
parent
bc16aae3b4
commit
7ea6076104
12
main.py
12
main.py
@ -2,6 +2,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unpacker
|
import unpacker
|
||||||
|
import setup
|
||||||
|
|
||||||
'''
|
'''
|
||||||
obtain new info for sites database
|
obtain new info for sites database
|
||||||
@ -25,6 +26,7 @@ function ai1wm_activate_plugins( $plugins ) {
|
|||||||
return update_option( AI1WM_ACTIVE_PLUGINS, $current );
|
return update_option( AI1WM_ACTIVE_PLUGINS, $current );
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
plugin_prefix = 'SERVMASK_PREFIX_'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
""" Entry of the ai1wm program. """
|
""" Entry of the ai1wm program. """
|
||||||
@ -40,5 +42,15 @@ if __name__ == '__main__':
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if os.path.isfile(args.target):
|
||||||
|
# check for database.sql and package.json
|
||||||
|
# Setup Site files
|
||||||
|
setup.WPSetup()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
35
unpacker.py
35
unpacker.py
@ -33,23 +33,6 @@ class Ai1wmUnpacker(tuple):
|
|||||||
|
|
||||||
return super(Ai1wmUnpacker, cls).__new__(cls, [path, name, size, time])
|
return super(Ai1wmUnpacker, cls).__new__(cls, [path, name, size, time])
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def unpack_header(cls, header):
|
|
||||||
""" Unpacks a binary header. """
|
|
||||||
|
|
||||||
if len(header) != cls.SIZE:
|
|
||||||
raise Exception('invalid header size')
|
|
||||||
|
|
||||||
if header == cls.EOF:
|
|
||||||
return cls()
|
|
||||||
|
|
||||||
return cls(
|
|
||||||
path=cls.s__(cls.__extract_field(header, cls._LOC_PATH)),
|
|
||||||
name=cls.s__(cls.__extract_field(header, cls._LOC_NAME)),
|
|
||||||
size=cls.__extract_int(header, cls._LOC_SIZE),
|
|
||||||
time=cls.__extract_int(header, cls._LOC_TIME),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def s__(cls, obj):
|
def s__(cls, obj):
|
||||||
"""
|
"""
|
||||||
@ -85,6 +68,23 @@ class Ai1wmUnpacker(tuple):
|
|||||||
obj = str(obj)
|
obj = str(obj)
|
||||||
return obj.encode('utf-8')
|
return obj.encode('utf-8')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def unpack_header(cls, header):
|
||||||
|
""" Unpacks a binary header. """
|
||||||
|
|
||||||
|
if len(header) != cls.SIZE:
|
||||||
|
raise Exception('invalid header size')
|
||||||
|
|
||||||
|
if header == cls.EOF:
|
||||||
|
return cls()
|
||||||
|
|
||||||
|
return cls(
|
||||||
|
path=cls.s__(cls.__extract_field(header, cls._LOC_PATH)),
|
||||||
|
name=cls.s__(cls.__extract_field(header, cls._LOC_NAME)),
|
||||||
|
size=cls.__extract_int(header, cls._LOC_SIZE),
|
||||||
|
time=cls.__extract_int(header, cls._LOC_TIME),
|
||||||
|
)
|
||||||
|
|
||||||
def pack(self):
|
def pack(self):
|
||||||
""" Packs to a binary header. """
|
""" Packs to a binary header. """
|
||||||
|
|
||||||
@ -154,7 +154,6 @@ class Ai1wmUnpacker(tuple):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
raise Exception('invalid header field')
|
raise Exception('invalid header field')
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __make_dirs(path, mode=0o777):
|
def __make_dirs(path, mode=0o777):
|
||||||
""" A simple wrapper of os.makedirs(), which does not raise exception if the leaf directory already exists. """
|
""" A simple wrapper of os.makedirs(), which does not raise exception if the leaf directory already exists. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user