def url_gen(schema='http://', min_hn_depth=2, max_hn_depth=4, hn_prefix=[], hn_suffix=[], min_path_depth=2, max_path_depth=4, path_prefix=[], path_suffix=[]): """URL generator.""" for x in utils.rand_gen(rand_url, **locals()): yield x
def path_gen(min_fn=1, max_fn=10, min_depth=1, max_depth=5, prefix=[], suffix=[]): """Path generator.""" for x in utils.rand_gen(rand_path, min_fn=min_fn, max_fn=max_fn, min_depth=min_depth, max_depth=max_depth, prefix=prefix, suffix=suffix): yield x
utils.show_spectrum(S) S = downsample(S, K) # utils.show_spectrum(S) data = slice_signal(S) return data if __name__ == '__main__': import audiobackend import Queue size = 1024 q_out = Queue.Queue() p = audiobackend.Play(channels=1, queue=q_out) x = utils.rand_gen(10240) Fcarr = 2000 Fsampl = 8000 K = 6 signal = modulate(x, Fcarr, Fsampl, K) y = demodulate(signal, Fcarr, Fsampl, K) x = x.tolist() # print len(x) # print len(y) # print x # print y if bool(utils.contains(x[0:196], y)) == False: # if bool(utils.contains(x, y)) == False: print "data error"
S = numpy.vectorize(complex)(I, Q) utils.show_spectrum(S) S = downsample(S, K) # utils.show_spectrum(S) data = slice_signal(S) return data if __name__ == '__main__': import audiobackend import Queue size = 1024 q_out = Queue.Queue() p = audiobackend.Play(channels=1, queue=q_out) x = utils.rand_gen(10240) Fcarr = 2000 Fsampl = 8000 K = 6 signal = modulate(x, Fcarr, Fsampl, K) y = demodulate(signal, Fcarr, Fsampl, K) x = x.tolist() # print len(x) # print len(y) # print x # print y if bool(utils.contains(x[0:196], y)) == False: # if bool(utils.contains(x, y)) == False: print "data error"
def varstr_gen(minlen=1, maxlen=64, chrset=string.letters + string.digits): """Variable-length string generator.""" for x in utils.rand_gen(rand_str, minlen, maxlen, chrset): yield x
def str_gen(len_=64, chrset=string.letters + string.digits): """Fixed-length string generator.""" for x in utils.rand_gen(rand_str, len_, len_, chrset): yield x
def int_gen(min=0, max=sys.maxint): """Integer generator.""" for x in utils.rand_gen(rand_int, min, max): yield x
def webagent_gen(agents=WEB_AGENTS): """Web agent generator.""" for x in utils.rand_gen(rand_webagent, agents): yield x
def host_gen(min_hn=3, max_hn=10, min_depth=2, max_depth=4, prefix=[], suffix=[]): """Host name generator.""" for x in utils.rand_gen(rand_host, **locals()): yield x
def status_gen(status_dist=HTTP_STATUS_DIST): """HTTP status code generator.""" for x in utils.rand_gen(rand_status, status_dist): yield x
def ip_gen(prefix=[]): """IP generator.""" for x in utils.rand_gen(rand_ip, prefix): yield x
def imsi_gen(): """IMSI generator.""" for x in utils.rand_gen(rand_imsi): yield x
def msisdn_gen(segs=MSISDN_SEGS, cc_prefix=False): """MSISDN generator.""" for x in utils.rand_gen(rand_msisdn, segs, cc_prefix): yield x