From 7ea60761048fc3759c0a4ff525b2d10098f80632 Mon Sep 17 00:00:00 2001 From: Bryson Date: Wed, 24 Apr 2024 22:11:54 -0500 Subject: [PATCH] some changes, starting wp setup --- main.py | 12 ++++++++++++ setup.py | 4 ++++ unpacker.py | 35 +++++++++++++++++------------------ 3 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 setup.py diff --git a/main.py b/main.py index f0dc3db..cd4446f 100644 --- a/main.py +++ b/main.py @@ -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) \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7765a01 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +class Setup(): + + def WPSetup(): + print('holder') diff --git a/unpacker.py b/unpacker.py index c29e1e6..056032b 100644 --- a/unpacker.py +++ b/unpacker.py @@ -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. """