コード例 #1
0
    def __init__(self, url, outlet_number, https_verify = True,
                 password = None, **kwargs):
        assert isinstance(url, str)
        assert isinstance(outlet_number, int) and outlet_number > 0
        assert password == None or isinstance(password, str)

        ttbl.power.impl_c.__init__(self, **kwargs)
        self.capture_program = commonl.ttbd_locate_helper(
            "raritan-power-capture.py",
            ttbl._install.share_path,
            log = logging, relsrcpath = ".")
        ttbl.capture.impl_c.__init__(
            self, False, "application/json", log = "text/plain")
        self.url = urllib.parse.urlparse(url)
        if password:
            self.password = commonl.password_get(
                self.url.netloc, self.url.username, password)
        else:
            self.password = None
        # note the indexes for the SW are 0-based, while in the labels
        # in the HW for humans, they are 1 based.
        self.outlet_number = outlet_number - 1
        self.https_verify = https_verify
        self._outlet_rpc = None
        url_no_password = "******" % (self.url.scheme, self.url.hostname)
        self.upid_set("Raritan PDU %s #%d" % (url_no_password, outlet_number),
                      url = url_no_password, outlet = outlet_number)
コード例 #2
0
ファイル: noyito.py プロジェクト: inakypg/tcf
    def __init__(self, noyito_component, noyito_obj, channels, **kwargs):
        """

        :param str channel_mode: passed straight to :mod:`ttbl.noyito-capture`.

           - *boolean:cutoff=1.3* or *onoff:cutoff=1.3*: interpret
             signal like a boolean value, cutting off at 1.3 Volts

        """
        assert isinstance(noyito_component, str)
        assert isinstance(channels, dict), \
            "channels: expected a dictionary, got %s" % type(channels)

        ttbl.capture.impl_c.__init__(self,
                                     False,
                                     mimetype="application/json",
                                     **kwargs)
        self.noyito_component = noyito_component
        self.upid = noyito_obj.upid
        self.capture_program = commonl.ttbd_locate_helper(
            "noyito-capture.py",
            ttbl._install.share_path,
            log=logging,
            relsrcpath=".")
        self.channell = []
        for channel, data in channels.items():
            assert isinstance(channel, int) and channel > 0 and channel <= 10, \
                "channel: channel descriptor has to be an integer 0-10," \
                " got %s" % type(channel)
            # matches ttbd/noyito-capture.py.transform.mode
            mode = data.get('mode', None)
            assert mode in ( None, 'mode', 'bool', 'onoff' ), \
                "channel mode has to be one of: None, mode, bool, onoff; " \
                " got %s" % mode
            name = data.get('mode', str(channel))
            assert isinstance(name, str), \
                "name: expected a string; got %s" % type(name)
            l = ["%s" % channel]
            for name, val in data.items():
                l.append("%s=%s" % (name, val))
            self.channell.append(":".join(l))
コード例 #3
0
                        default=False,
                        help="check from the begining of the boot")
arg_parser.add_argument("-n",
                        "--dry-run",
                        action='store_true',
                        default=False,
                        help="only show what would it do")
args = arg_parser.parse_args()
logging.basicConfig(level=args.level, format="%(levelname)s: %(message)s")

#
# Read configuration and decide what to watch
#

_ttbd_hw_health_monitor_driver_rebind_path = \
    commonl.ttbd_locate_helper("ttbd-hw-healthmonitor-driver-rebind.py",
                               log = logging)
logging.debug("Found helper %s", _ttbd_hw_health_monitor_driver_rebind_path)

args.config_path = os.path.expanduser(args.config_path)
if args.config_path != [""]:
    commonl.config_import([args.config_path], re.compile("^conf[-_].*.py$"))

journal = systemd.journal.Reader()
journal.log_level(systemd.journal.LOG_INFO)
logging.debug("opened journal")

systemd.daemon.notify("READY=1")

journal.this_boot(args.bootid)
journal.this_machine()
logging.debug("journal: filtering for kernel messages")
コード例 #4
0
                        help = "check from the begining of the boot")
arg_parser.add_argument("-n", "--dry-run",
                        action = 'store_true', default = False,
                        help = "only show what would it do")
args = arg_parser.parse_args()
logging.basicConfig(
    level = args.level,
    format = "%(levelname)s: %(message)s")

#
# Read configuration and decide what to watch
#

_ttbd_hw_health_monitor_driver_rebind_path = \
    commonl.ttbd_locate_helper("ttbd-hw-healthmonitor-driver-rebind.py",
                               ttbl._install.share_path,
                               log = logging)
logging.debug("Found helper %s", _ttbd_hw_health_monitor_driver_rebind_path)

args.config_path = os.path.expanduser(args.config_path)
if args.config_path != [ "" ]:
    commonl.config_import([ args.config_path ], re.compile("^conf[-_].*.py$"))

journal = systemd.journal.Reader()
journal.log_level(systemd.journal.LOG_INFO)
logging.debug("opened journal")

systemd.daemon.notify("READY=1")

journal.this_boot(args.bootid)
journal.this_machine()