some changes, starting wp setup

This commit is contained in:
Bryson Shepard 2024-04-24 22:11:54 -05:00
parent bc16aae3b4
commit 7ea6076104
3 changed files with 33 additions and 18 deletions

12
main.py
View File

@ -2,6 +2,7 @@ import argparse
import os
import sys
import unpacker
import setup
'''
obtain new info for sites database
@ -25,6 +26,7 @@ function ai1wm_activate_plugins( $plugins ) {
return update_option( AI1WM_ACTIVE_PLUGINS, $current );
}
'''
plugin_prefix = 'SERVMASK_PREFIX_'
if __name__ == '__main__':
""" Entry of the ai1wm program. """
@ -40,5 +42,15 @@ if __name__ == '__main__':
except Exception as e:
print(e)
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)

4
setup.py Normal file
View File

@ -0,0 +1,4 @@
class Setup():
def WPSetup():
print('holder')

View File

@ -33,23 +33,6 @@ class Ai1wmUnpacker(tuple):
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
def s__(cls, obj):
"""
@ -85,6 +68,23 @@ class Ai1wmUnpacker(tuple):
obj = str(obj)
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):
""" Packs to a binary header. """
@ -154,7 +154,6 @@ class Ai1wmUnpacker(tuple):
except ValueError:
raise Exception('invalid header field')
@staticmethod
def __make_dirs(path, mode=0o777):
""" A simple wrapper of os.makedirs(), which does not raise exception if the leaf directory already exists. """