Esempio n. 1
0
    def __init__(self, verbose) -> None:
        super().__init__()

        # --------------------------- import 3rd/non-class --------------------------- #
        import lib.etc as etc
        import os

        # ----------------------------- import libraries ----------------------------- #
        from lib.api import api
        from lib.detection import detection
        from lib.data import data
        from lib.config import config
        from lib.cli import cli
        cli = cli(verbose)

        # ----------------------------- Custom exceptions ---------------------------- #
        import lib.issue as SPMCLIExceptions
        self.SPMCLIExceptions = SPMCLIExceptions

        # -------------------------------- get config -------------------------------- #
        self.config = config(verbose)

        # ----------------------- initialise all other classes ----------------------- #
        self.data = data(verbose)
        self.os = os
        self.cli = cli
        self.etc = etc
        self.json = etc.getJson()
        self.api = api(verbose)
        self.detection = detection(verbose)
        self.log = cli.verbose
        self.verbose = verbose
Esempio n. 2
0
    def connect_dbs():

        # read database configuration
        params = config()
        # connect to the PostgreSQL database
        conn = psycopg2.connect(**params)

        return conn
Esempio n. 3
0
 def __init__(self,Baudrate = 115200, dev = "/dev/tty0", data_mode = 1, address=0x47):
     self.address = address
     self.data_mode = data_mode #1 :uart   0: i2c
     self.Baudrate = Baudrate
     self.dev = dev
     self.com = config(Baudrate , dev, data_mode, address)
     self.angle1 = 0
     self.angle2 = 0
     self.read_file()
Esempio n. 4
0
    def create_hdd(self, vmname, disksize):
        hddpath = os.path.join(config('hdd-dir'),
                               '%s.vdi' % os.path.basename(vmname))

        ctlname = 'IDE Controller'
        self._call('createhd', filename=hddpath, size=disksize)
        self._call('storagectl', vmname, name=ctlname, add='ide')
        self._call('storageattach', vmname, storagectl=ctlname,
                   type='hdd', device=0, port=0, medium=hddpath)
Esempio n. 5
0
    def saveConfig(self):
        """ Actions to take when the 'save config' menu item is selected """

        # Call dialog box to select the configuration file
        self.loader = FileSelector("saveConfig")

        # Save the raob request into the configuration file
        self.raob.request.set_config(self.loader.get_file())
        configfile = config(self.log)
        configfile.write(self.raob.request)
Esempio n. 6
0
    def attach_iso(self, vmname, filename):
        isopath = os.path.join(config('iso-dir'), os.path.basename(filename))

        ctlname = 'IDE Controller'
        self._call('storageattach',
                   vmname,
                   storagectl=ctlname,
                   type='dvddrive',
                   port=1,
                   device=0,
                   medium=isopath)
Esempio n. 7
0
    def __init__(self,verbose) -> None:
        super().__init__()
        
        #Set verbose flag
        self.verbosef = verbose

        #Import config lib
        from lib.config import config
        from lib.detection import detection
        self.detection = detection(verbose)
        self.config = config(verbose)
        self.shipping = self.config.shipping()
Esempio n. 8
0
    def create_hdd(self, vmname, disksize):
        hddpath = os.path.join(config('hdd-dir'),
                               '%s.vdi' % os.path.basename(vmname))

        ctlname = 'IDE Controller'
        self._call('createhd', filename=hddpath, size=disksize)
        self._call('storagectl', vmname, name=ctlname, add='ide')
        self._call('storageattach',
                   vmname,
                   storagectl=ctlname,
                   type='hdd',
                   device=0,
                   port=0,
                   medium=hddpath)
Esempio n. 9
0
def to_ftp(outfile, request, log=""):
    """
    return: status messages
    """

    # Get the user specified ftp status and dirs from the YAML config file
    # given on the command line. If there is no config file, then can't ftp/cp.
    # Let user know and return.
    configfile = config(log)
    if os.path.exists(os.path.join(os.getcwd(), request.get_config())):
        configfile.read(request)
    else:
        return("WARNING: No config file defined so ftp status not set." +
               " Downloaded files are in working dir.")

    # Have a config file. Get ftp status, or warn user not set
    ftp_status = configfile.get_ftp_status()

    if ftp_status is True:  # USER IS REQUESTING FTP TO FTP SERVER AND DIR
        ftp_server = configfile.get_ftp_server()
        if ftp_server is None:
            return("Could not FTP files")
        ftp_dir = configfile.get_ftp_dir()
        if ftp_dir is None:
            return("Could not FTP files")

        # Connect to server and put new file
        # ftp = FTP(ftp_server,'USERNAME','PASSWORD')
        try:
            ftp = FTP(ftp_server, 'anonymous', '')
            ftp.cwd(ftp_dir)
            f = open(outfile, 'rb')
            ftp.storbinary(f'STOR ' + outfile, f)
            ftp.quit()
            return("FTPd " + outfile + " to " + ftp_server + "/" + ftp_dir)
        except Exception:
            return("ERROR: FTP transfer failed for file " + outfile)

    elif ftp_status is False:

        cp_dir = configfile.get_cp_dir()
        if cp_dir is None:
            return("Could not copy files")

        # Move downloaded image to dest file in ftp_dir
        shutil.copyfile(outfile, cp_dir + "/" + outfile)
        return("copied " + outfile + " to " + cp_dir)

    else:  # ftp_status is None
        return("No FTP status set - files not copied or ftp'd")
Esempio n. 10
0
    def set_args(self, args):
        """
        Populate the request with values from the command line or from a config
        file.
        """
        # Set requested region, type, and date to values requested via command
        # line
        status = self.request.set_prov(args)

        # If --config supplied, set request to values in config file
        if self.request.get_config() != '':
            configfile = config()
            status = configfile.read(self.request)

        return(status)
Esempio n. 11
0
    def __init__(self,verbose) -> None:
        super().__init__()

        import requests
        self.requests = requests

        #from lib.etc import getJson
        from lib.cli import cli;cli=cli(verbose)
        from lib.config import config
        #self.json = getJson() - can just use requests.json
        self.config = config(verbose)
        self.config = self.config.getConfig()
        #if self.config == False: raise FileNotFoundError("Missing configuration")

        self.log = cli.verbose
Esempio n. 12
0
    def loadConfig(self):
        """ Actions to take when the 'Load config' menu item is selected """
        # This has to be self.editor (not just editor) to avoid garbage
        # collection or the GUIconfig window won't appear.
        configfile = config(self.log)

        # Call dialog box to select the configuration file
        self.loader = FileSelector("loadConfig")

        # Clear the previously loaded config so don't get conflicts
        configfile.clear(self.raob.request)

        # Load the configuration into the raob request
        self.raob.request.set_config(self.loader.get_file())
        configfile.read(self.raob.request)

        # Update the displayed selections in the configedit portion
        # of the GUI
        self.update_displayed_config()
Esempio n. 13
0
    def test_config(self):
        """ Make sure code checks for correct metadata for ftp status in
        config file. """
        configfile = config()
        self.raob.request.set_config("../test/data/config_cp.yml")
        configfile.read(self.raob.request)
        ftp_status = configfile.get_ftp_status()
        self.assertFalse(ftp_status)
        cp_dir = configfile.get_cp_dir()
        self.assertEqual(cp_dir, '/net/iftp2/pub/incoming/catalog/test')

        self.raob.request.set_config("../test/data/config_ftp.yml")
        configfile.read(self.raob.request)
        ftp_status = configfile.get_ftp_status()
        self.assertTrue(ftp_status)
        ftp_server = configfile.get_ftp_server()
        self.assertEqual(ftp_server, 'catalog.eol.ucar.edu')
        ftp_dir = configfile.get_ftp_dir()
        self.assertEqual(ftp_dir, 'pub/incoming/catalog/test')
Esempio n. 14
0
if '-v' in sys.argv: verbose = True
else: verbose = False

# ---------------------------------------------------------------------------- #
#                              Lib package imports                             #
# ---------------------------------------------------------------------------- #

# ------------------- Load configuration and cli libraries ------------------- #
#
# Load config and cli libraries so we can prepare the configuration
# files and cli library (so we can access verbose) prior to loading
# other libraries and the program
#
from lib.config import config
from lib.cli import cli
config = config(verbose)
cli = cli(verbose)  # Initialise config and cli libs

# -------------------------- Generate configuration -------------------------- #
if config.getConfig() == {}:
    cli.verbose("Building config")
    config.buildConfig('default')
    print(
        "First run! Hi there, default configuration generated and saved to ~/.spm/config"
    )
else:
    cli.verbose("Config found")
    cli.verbose(f"Configuration: {config.getConfig()}")

# -------------------------------- Import libs ------------------------------- #
#
Esempio n. 15
0
 def createvm(self, vmname):
     self._call('createvm', name=vmname, basefolder=config('vms-dir'),
                register=True)
Esempio n. 16
0
 def push_iso(self, f, filename):
     isopath = os.path.join(config('iso-dir'), os.path.basename(filename))
     f.save(isopath)
Esempio n. 17
0
    def attach_iso(self, vmname, filename):
        isopath = os.path.join(config('iso-dir'), os.path.basename(filename))

        ctlname = 'IDE Controller'
        self._call('storageattach', vmname, storagectl=ctlname,
                   type='dvddrive', port=1, device=0, medium=isopath)
Esempio n. 18
0
                        default=9002,
                        type=int,
                        help='Port to listen on.')
    parser.add_argument('-s', '--settings', type=str, help='Settings file.')

    args = parser.parse_args()

    if args.debug:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.settings:
        load_config(args.settings)

    required = 'iso-dir', 'hdd-dir', 'vms-dir'
    for row in required:
        if not config(row):
            log.error(
                'The %r value is missing in your configuration! '
                'Please provide it and run VBoxRPC again.', row)
            exit(1)

        path = config(row)
        if not os.path.isdir(path):
            log.info('Creating directory %r', path)
            os.makedirs(path)

    app = create_app(debug=args.debug)
    app.run(host=args.host, port=args.port)
Esempio n. 19
0
 def createvm(self, vmname):
     self._call('createvm',
                name=vmname,
                basefolder=config('vms-dir'),
                register=True)
Esempio n. 20
0
         if c == '2':
             clear()
             menu()
             bomber()
         if c == '3':
             clear()
             menu()
             wdnfm()
         if c == '4':
             clear()
             menu()
             unfollow()
         elif c == '91':
             clear()
             menu()
             config('instagram')
         elif c == 'c':
             clear()
             menu()
             print(printMenu.instagramMenu)
         elif c == 'b':
             clear()
             menu()
             print (printMenu.mainMenu)
             break
         elif c == 'q':
             sys.exit(" Please consider donating. Good bye")
         else:
             print(' Please use a valid options')
 elif (c == '2'):
     clear()
Esempio n. 21
0
exl_mode.add_argument('--search', help='Search for encrypted messages on server.', action='store_true')
grp_mode.add_argument('--repack', help='Re-encrypt messages after searching or single selection.', action='store_true')
exl_mode.add_argument('--list', help='List Mailbox folders.', action='store_true')

grp_gpg = args.add_argument_group('gpg key selection')
grp_gpg.add_argument('--delkey', metavar='FNGPRNT', action='append', help='Remove keys from recipient list. (multi)', default=[])
grp_gpg.add_argument('--addkey', metavar='FNGPRNT', action='append', help='Add keys to recipient list. (multi)', default=[])
grp_gpg.add_argument('--del-all-keys', action='store_true', help='Clear recipient list before adding with --addkey.')
grp_gpg.add_argument('--only-for', metavar='FNGPRNT', help='Only repack messages that were encrypted to this key.')
grp_gpg.add_argument('--always-trust', action='store_true', help='Always trust the recipient keys and skip trust validation.')


args = args.parse_args()

# get configuration and initialize gpg
server, username, password = config(args.config, args.account)
gpg = gnupg.GPG(use_agent=True)
mailbox = imap.quoted_mailbox(args.mailbox)

# open imap mailbox
with imap.session(server, username, password) as session:

  # LIST ALL FOLDERS
  if args.list:
    print(imap.ls(session))

  # SEARCH AND DISPLAY ENCRYPTED MESSAGES
  if args.search:
    
    print(f'Searching for encrypted messages in {mailbox} ...')
    mime, inline = imap.search_encrypted(session, mailbox)
Esempio n. 22
0
 def push_iso(self, f, filename):
     isopath = os.path.join(config('iso-dir'), os.path.basename(filename))
     f.save(isopath)
Esempio n. 23
0
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--debug', action='store_true', help='Enable debugging mode. Do *NOT* do this on production systems as it allows RCE.')
    parser.add_argument('--host', default='0.0.0.0', type=str, help='Host to listen on.')
    parser.add_argument('--port', default=9002, type=int, help='Port to listen on.')
    parser.add_argument('-s', '--settings', type=str, help='Settings file.')

    args = parser.parse_args()

    if args.debug:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.settings:
        load_config(args.settings)

    required = 'iso-dir', 'hdd-dir', 'vms-dir'
    for row in required:
        if not config(row):
            log.error('The %r value is missing in your configuration! '
                      'Please provide it and run VBoxRPC again.', row)
            exit(1)

        path = config(row)
        if not os.path.isdir(path):
            log.info('Creating directory %r', path)
            os.makedirs(path)

    app = create_app(debug=args.debug)
    app.run(host=args.host, port=args.port)