コード例 #1
0
ファイル: init.py プロジェクト: Otti0815/picosafe_login
parser.add_option("-i", "--id",          action="store", type="int",     dest="id",       help="Set id (integer)",                    default=0)

(options, args) = parser.parse_args()

company  = options.company
owner    = options.owner
desc     = options.desc
seed     = options.password
lock     = options.lock
id       = options.id

def ok(string, bool):
  print string+"... ",
  if bool:
    print "ok"
  else:
    print "fail"
    exit(1)

ok("set_owner",     picosafelogin.set_owner(owner))
ok("set_desc",      picosafelogin.set_description(desc))
ok("set_id",        picosafelogin.set_id(id))
ok("set_company",   picosafelogin.set_company(company))
ok("set_seed",      picosafelogin.set_seed(seed))
ok("set_timestamp", picosafelogin.set_timestamp(int(time()), seed))
#print
#print seed

if lock:
    ok("set_lock", picosafelogin.set_lock())
コード例 #2
0
ファイル: test_id.py プロジェクト: Otti0815/picosafe_login
#!/usr/bin/python

from __future__ import division
import picosafelogin
from optparse import OptionParser
from sys import exit
from random import random

parser = OptionParser()
parser.add_option("-n", "--tries", action="store", type="int",    dest="tries", help="number of tries", default=1000)

(options, args) = parser.parse_args()

tries = options.tries

for i in xrange(tries):
  id_1 = int(random()*2**31)
  picosafelogin.set_id(id_1)
  id_2 = picosafelogin.get_id()

  if id_1 != id_2:
    print "%d != %d (diff: %d)" % (id_1, id_2, id_1-id_2)
    exit(1)
  
  if (i % 10) == 0:
    print "% 2.2f%%" % (i/tries*100)