Exemple #1
0
 def __init__(self, model_name, device='CPU', extensions=None):
     '''
     TODO: Use this to set your instance variables.
     '''
     Generic.__init__(self, model_name, device, extensions)
     self.input_shape = self.model.input_info[
         'left_eye_image'].input_data.shape
Exemple #2
0
    def __init__(self):
        Generic.__init__(self)

        """ Markup element tags """
        self._bold = ['**', '**']
        self._italic = ['//', '//']
        self._underlined = ['__', '__']
        self._highlighted = ['%%', '%%']
        self._list = ['', '']
        self._item = ['* ', '']
        self._image = ['{{', '}}']
Exemple #3
0
    def __init__(self):
        Generic.__init__(self)

        """ Markup element tags """
        self._bold = ['<b>', '</b>']
        self._italic = ['<i>', '</i>']
        self._underlined = ['<u>', '</u>']
        self._highlighted = ['<span style="background: yellow;">', '</span>']
        self._list = ['<ul>', '</ul>']
        self._item = ['<li>', '</li>']
        self._image = ['img src="', '">']
Exemple #4
0
def run(delay, sensor_type, pin, webhook, source, metric_prefix, output,
        format):
    sensor = None
    is_polling = False
    if sensor_type.startswith('DHT'):
        pin = int(pin)
        sensor = Temp(source, metric_prefix, output, sensor_type, pin, format)
        is_polling = True
    elif sensor_type == 'HC-SRO':
        pins = pin.split(',')
        sensor = Distance(source, metric_prefix, output, sensor_type,
                          int(pins[0]), int(pins[1]), format)
        is_polling = True
    elif sensor_type == 'SSM-1':
        pin = int(pin)
        sensor = Generic(source, metric_prefix, output, sensor_type, pin,
                         'Sound')
    elif sensor_type == 'HC-SR501':
        pin = int(pin)
        sensor = Motion(source, metric_prefix, output, sensor_type, pin)
    elif sensor_type == 'SEO53':
        pin = int(pin)
        sensor = Generic(source, metric_prefix, output, sensor_type, pin,
                         'Vibration')
    elif sensor_type == 'SEO23':
        pin = int(pin)
        sensor = Generic(source, metric_prefix, output, sensor_type, pin,
                         'Tilt')
    elif sensor_type == 'YL-69':
        pin = int(pin)
        sensor = Moisture(source, metric_prefix, output, sensor_type, pin,
                          'Moisture', delay)
    else:
        sensor = Host(source, metric_prefix, output)
        is_polling = True

    while True:
        sensor.get_info()
        metrics = sensor.format_metrics()
        if webhook is not None:
            send_metrics(metrics, output, webhook, source)
        else:
            print(metrics)
        # check if the senor is something that needs to poll for results based on a delay.
        if is_polling:
            time.sleep(delay)
 def __init__(self, model_name, device='CPU', extensions=None):
     '''
     TODO: Use this to set your instance variables.
     '''
     Generic.__init__(self, model_name, device, extensions)
Exemple #6
0
def main():

    parser = argparse.ArgumentParser(
        description=
        "Gunpack -- Tries to unpack binary ;-)\nWhen the unpacking is successful, Gunpack creates 2 files :\n\t- <filename_of_binary>_<md5_of_binary>_dump.exe : Memory dump of the unpacked binary\n\t- <filename_of_binary>_<md5_of_binary>_unpacked.exe : Real PE of the unpacked binary"
    )
    parser.add_argument("--verbose",
                        "-v",
                        action="count",
                        default=2,
                        help="Increase verbosity")
    parser.add_argument("--file",
                        "-f",
                        dest='binary',
                        type=str,
                        action="store",
                        help=u"Binary file to unpack",
                        required=True)
    parser.add_argument(
        "--output-directory",
        "-o",
        "-od",
        dest='out',
        type=str,
        action="store",
        help=
        u"Directory where you want to save the unpacked binary. If the option is not set, the unpacked files are saved in the directory of the binary",
        required=False)
    parser.add_argument("--script",
                        "-s",
                        action="store",
                        help="script to use",
                        dest='script',
                        required=True)

    options = parser.parse_args()
    verbosity = max(1, 50 - 10 * (options.verbose))
    logging.basicConfig(format="%(levelname)-5s: %(message)s", level=verbosity)
    logobj = logging.getLogger("gunpack")

    #do not close the file here in order to avoid binary removal
    input_file_abs = os.path.abspath(options.binary)
    filename = os.path.basename(input_file_abs)

    if options.out is not None:
        out = os.path.abspath(options.out)
        if not (os.path.isdir(out)):
            logobj.error("directory \"%s\" does not exist" % out)
            quit()
    else:
        out = os.path.dirname(input_file_abs)

    device_name = "\\\\.\\MyDevice"

    if (options.script == "log"):
        unpacker = Log(options.binary)
    elif (options.script == "upack"):
        unpacker = Upack(options.binary)
    elif (options.script == "generic"):
        unpacker = Generic(options.binary)
    elif (options.script == "mpress"):
        unpacker = Mpress(options.binary)
    else:
        print "Unknown unpacker !"

    unpacker.set_params(logobj,
                        device_name,
                        kernel_log=0,
                        output_directory=out)

    unpacker.run(1)

    f.close()
Exemple #7
0
 def __init__(self, source, metric_prefix, output, code, pin, metric_name,
              delay):
     Generic.__init__(self, source, metric_prefix, output, code, pin,
                      metric_name)
     self.delay = delay