Exemple #1
0
def upload():
    sys.argv[0] = "feral_decoder_upload"
    args = init(
        "feral_decoder_upload uploads any cache entries and then archives the cache entry.",
        args=[{
            _as: ["--no_decache"],
            _kw: {
                "action":
                "store_true",
                "default":
                False,
                "dest":
                "no_decache",
                "help":
                "This will process the cache" +
                "file normally, but will not remove it from the cache. Normally used for testing."
            }
        }, {
            _as: ["--ignore_ts"],
            _kw: {
                "action": "store_true",
                "default": False,
                "dest": "ignore_ts",
                "help": "Ignore the nodes timestamp file."
            }
        }])
    from feral_decoder.upload import Uploader
    logger.log(logging.TRACE, "Args: %s" % args)
    Uploader(args).run()
Exemple #2
0
def main():
    args = init(
        "feral_decoder_create_streams create all of the sata streams in the sensor cloud.",
        args=[
            {
                "args": ["-r", "--remove"],
                "kwargs": {
                    "action": 'store_true',
                    "default": False,
                    "help": "Remove the streams instead of creating them."
                }
            },
        ])

    if args.remove:
        remove_streams()
    else:
        add_streams()
Exemple #3
0
def unpack():

    args = init("feral_json_unpack reads in a newline-delimited JSON file and unpacks it into the cache directory.",
         args=[
                 {
                    "args":["file"],
                    "kwargs":
                    {
                      "help": "The newline terminated JSON file to unpack"
                    }
                  },
                {
                    "args":["prefix"],
                    "kwargs":
                    {
                      "help": "the prefix to add to the cache entries"
                    }
                  },
         ]
        )
    from FeralDecoder_Paths import cache_dir
    logger = logging.getLogger("Unpacker")
    with open(args.file, "r") as din:
        while True:
            data = din.readline().strip()
            if len(data) > 0:
                dat = json.loads(data)
                fn = "%s%s.json"%(args.prefix, dat["rxInfo"][0]["time"].replace(":", "_"))
                cache_fn = os.path.join(cache_dir, fn)
                if not os.path.exists(cache_fn):
                    with open(cache_fn, "w") as dout:
                        json.dump(dat, dout)
                        logger.log(logging.TRACE, "Created cache file: %s"%cache_fn)
                else:
                    logger.log(logging.TRACE, "Skipped file: %s"%cache_fn)
            else:
                break
def main():
    init(
        "feral_decoder_create_groups creates the sensor-cloud.io groups to attach the data streams and locations to."
    )
    run()
Exemple #5
0
def unpack():
    init(
        "feral_json_unpack reads in a newline-delimited JSON file and unpacks it into the cache directory."
    )