Esempio n. 1
0
 def setimage():
     parser = argparse.ArgumentParser(
         description="Maps a image hash to a file path in the database",
         usage='''usage:
 networkcli.py setimage [-f FILEPATH]''')
     parser.add_argument('-f', '--filepath', help="a path to the image")
     args = parser.parse_args(sys.argv[2:])
     with open(args.filepath, "r") as f:
         image = f.read()
     d = digest(image)
     h = HashMap()
     h.insert(d, args.filepath)
     print h.get_file(d)
Esempio n. 2
0
 def setimage():
     parser = argparse.ArgumentParser(
         description="Maps a image hash to a file path in the database",
         usage='''usage:
 networkcli.py setimage [-f FILEPATH]''')
     parser.add_argument('-f', '--filepath', help="a path to the image")
     args = parser.parse_args(sys.argv[2:])
     with open(args.filepath, "r") as f:
         image = f.read()
     d = digest(image)
     h = HashMap()
     h.insert(d, args.filepath)
     print h.get_file(d)
Esempio n. 3
0
 def setprofile():
     parser = argparse.ArgumentParser(
         description="Sets a profile in the database.",
         usage='''usage:
 networkcli.py setprofile [options]''')
     parser.add_argument('-n', '--name', help="the name of the user/store")
     parser.add_argument('-o', '--onename', help="the onename id")
     parser.add_argument('-a',
                         '--avatar',
                         help="the file path to the avatar image")
     parser.add_argument('-hd',
                         '--header',
                         help="the file path to the header image")
     parser.add_argument(
         '-c',
         '--country',
         help=
         "a string consisting of country from protos.countries.CountryCode")
     # we could add all the fields here but this is good enough to test.
     args = parser.parse_args(sys.argv[2:])
     p = Profile()
     u = objects.Profile()
     h = HashMap()
     if args.name is not None:
         u.name = args.name
     if args.country is not None:
         u.location = countries.CountryCode.Value(args.country.upper())
     if args.onename is not None:
         u.handle = args.onename
     if args.avatar is not None:
         with open(args.avatar, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.avatar_hash = hash_value
         h.insert(hash_value, args.avatar)
     if args.header is not None:
         with open(args.header, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.header_hash = hash_value
         h.insert(hash_value, args.header)
     u.encryption_key = KeyChain().encryption_pubkey
     p.update(u)
Esempio n. 4
0
 def setprofile():
     parser = argparse.ArgumentParser(
         description="Sets a profile in the database.",
         usage='''usage:
 networkcli.py setprofile [options]''')
     parser.add_argument('-n', '--name', help="the name of the user/store")
     parser.add_argument('-o', '--onename', help="the onename id")
     parser.add_argument('-a', '--avatar', help="the file path to the avatar image")
     parser.add_argument('-hd', '--header', help="the file path to the header image")
     parser.add_argument('-c', '--country',
                         help="a string consisting of country from protos.countries.CountryCode")
     # we could add all the fields here but this is good enough to test.
     args = parser.parse_args(sys.argv[2:])
     p = Profile()
     u = objects.Profile()
     h = HashMap()
     if args.name is not None:
         u.name = args.name
     if args.country is not None:
         u.location = countries.CountryCode.Value(args.country.upper())
     if args.onename is not None:
         u.handle = args.onename
     if args.avatar is not None:
         with open(args.avatar, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.avatar_hash = hash_value
         h.insert(hash_value, args.avatar)
     if args.header is not None:
         with open(args.header, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.header_hash = hash_value
         h.insert(hash_value, args.header)
     u.encryption_key = KeyChain().encryption_pubkey
     p.update(u)