コード例 #1
0
    def setup(self, **kwargs):
        global Gd_args
        global Gstr_name
        global Gstr_description
        global Gstr_version

        str_defIP = [
            l for l in (
                [
                    ip
                    for ip in socket.gethostbyname_ex(socket.gethostname())[2]
                    if not ip.startswith("127.")
                ][:1],
                [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close())
                  for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]
                  ][0][1]]) if l
        ][0][0]
        str_defIPswift = str_defIP

        if 'HOST_IP' in os.environ:
            str_defIP = os.environ['HOST_IP']
            str_defIPswift = os.environ['HOST_IP']

        # For newer docker-compose
        try:
            swift_service = socket.gethostbyname('swift_service')
            if swift_service != "127.0.0.1":
                str_defIPswift = str_defIP
        except:
            pass

        for k, v in kwargs.items():
            if k == 'args': Gd_args = v
            if k == 'name': Gstr_name = v
            if k == 'desc': Gstr_description = v
            if k == 'ver': Gstr_version = v

        self.verbosity = int(Gd_args['verbosity'])
        self.dp = debug(verbosity=self.verbosity)
        self.args = Gd_args

        self.col2_print("This host IP:", str_defIPswift)
        self.col2_print("Self service address:", Gd_args['ipSelf'])
        self.col2_print("Self service port:", Gd_args['portSelf'])
        self.col2_print("Swift service address:", Gd_args['ipSwift'])
        self.col2_print("Swift service port:", Gd_args['portSwift'])
        self.col2_print("Server listen forever:", Gd_args['b_forever'])
        self.col2_print("Return HTTP responses:", Gd_args['b_httpResponse'])

        self.dp.qprint(Colors.LIGHT_GREEN +
                       "\n\n\t\t\tWaiting for incoming data...\n" +
                       Colors.NO_COLOUR,
                       level=1,
                       syslog=False)
コード例 #2
0
ファイル: pfmisc2.py プロジェクト: FNNDSC/pfmisc
    def __init__(self, *args, **kwargs):
        """

        Holder for constructor of class -- allows for explicit setting
        of member 'self' variables.

        :return:
        """
        self.LC = 40
        self.RC = 40
        self.args = None
        self.str_desc = 'pfmisc'
        self.str_name = self.str_desc
        self.str_version = ''

        self.dp = debug(verbosity=1, within='pfmisc2')

        self.dp2 = debug(verbosity=1,
                         within='pfmisc2',
                         debugToFile=True,
                         debugFile='/tmp/pfmisc2.txt')
コード例 #3
0
ファイル: pfioh.py プロジェクト: FNNDSC/pfioh-flask
    def setup(self, **kwargs):
        global Gd_internalvar
        for k, v in kwargs.items():
            if k == 'args': self.args = v
            if k == 'desc': self.str_desc = v
            if k == 'ver': self.str_version = v

        self.str_fileBase = "received-"
        self.str_storeBase = self.args['storeBase']
        self.b_createDirsAsNeeded = self.args['b_createDirsAsNeeded']

        self.str_unpackDir = self.args['storeBase']
        self.b_removeZip = False
        self.b_swiftStorage = self.args['b_swiftStorage']

        Gd_internalvar['httpResponse'] = self.args['b_httpResponse']
        Gd_internalvar['name'] = self.str_name
        Gd_internalvar['version'] = self.str_version
        Gd_internalvar['createDirsAsNeeded'] = self.args[
            'b_createDirsAsNeeded']
        Gd_internalvar['storeBase'] = self.args['storeBase']
        Gd_internalvar['b_swiftStorage'] = self.args['b_swiftStorage']
        Gd_internalvar['verbosity'] = int(self.args['verbosity'])

        self.verbosity = Gd_internalvar['verbosity']

        self.dp = debug(verbosity=self.verbosity)

        self.dp.qprint(self.str_desc)
        if self.args['b_tokenAuth']:
            Gd_internalvar['b_tokenAuth'] = True
            self.config = configparser.ConfigParser()
            if self.args['str_tokenPath'] != '':
                self.config.read(self.args['str_tokenPath'])
            else:
                self.config.read("pfioh_config.cfg")
            AUTH_TOKEN = str(self.config.get('AUTH TOKENS', 'token'))
            Gd_internalvar['authModule'] = AUTH_TOKEN

        self.col2_print("Listening on address:", self.args['ip'])
        self.col2_print("Listening on port:", self.args['port'])
        self.col2_print("Server listen forever:", self.args['b_forever'])
        self.col2_print("Return HTTP responses:", self.args['b_httpResponse'])
        self.col2_print("Authorization enabled:", self.args['b_tokenAuth'])

        self.dp.qprint(Colors.BLINK_GREEN +
                       "\n\n\t\t\t\tWaiting for incoming data...\n\n" +
                       Colors.NO_COLOUR,
                       flush=True,
                       syslog=False)
コード例 #4
0
ファイル: pfmisc2.py プロジェクト: FNNDSC/pfmisc
    def __init__(self, *args, **kwargs):
        """
        """

        self.dp = debug(verbosity=0, level=-1, within="someOtherClass2")