def workload(meta): x, y = meta try: pg_get = timeout(timeout=random.randint(13, 15))(pg.get) # TODO: do more self-understanding like that. p = pg_get(y) print("fetching success") # print("fetching success") up_time = timeout(timeout=random.randint(7, 11))(up) up_time(x, p) # TODO: find out the cause of the freeze. # TODO: automatically relaunch the entire program in .cmd file. except: print("fetching error") return
def getOutput(remote_conn): timeall = 10 while timeall >= 0: try: output = timeout(0.1)(remote_conn.recv) output = output(1000) print(output) print(type(output)) except: e = traceback.format_exc() print(e) # it was stuck. once again. we should use that timer. # i want to see some web repl. #result = stdout.read() #while not stdout.channel.exit_status_ready(): # # Only print data if there is data to read in the channel # if stdout.channel.recv_ready(): # rl, wl, xl = select.select([stdout.channel], [], [], 0.0) # if len(rl) > 0: # Print data from stdout # print(stdout.channel.recv(1024),) # this is not good. #if not result: # search for possible errors! # errors are sweet? # it is all connected. # does the order matters? # print(output.decode()) #print(output) #print(type(output)) # code is intepretable for shell but no unicode support? # print(output) # what is the color? # check it? # time.sleep(0.1) timeall -= 1 if timeall <= 0: break print("next_session")
def the_loop(a): stdt = time.time() # private_key = paramiko.RSAKey.from_private_key_file( # '/root/.ssh/id_rsa') # 使用目标的私钥来登录 ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # ssh.connect(hostname='127.0.0.1',port=22,username='******',pkey=private_key) # we will do recording later. # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # 连接服务器 ssh.connect(hostname='192.168.43.52', port=23, username='******', password='') # it is my system password after all. #cmd = 'yes' #stdin, stdout, stderr = ssh.exec_command(cmd) timestamp = time.time() # accept float? remote_conn = ssh.invoke_shell() # nothing is like this. # remote_conn.send("python\n") # what about errors? time.sleep(2) # you even have that shell thing! # remote_conn.send("yes\n") # yes! it does matters. # by the way, I f*****g hate shell command typing. It is awful. # what about networking and GUI clicking? # same to me! ok? # output = remote_conn.recv(1000) # get useless shit. remote_conn.recv(1000) # remote_conn.send("happybirthday\n") # a = "msfconsole" remote_conn.send(autoreturn(a)) # command_init = [a, 0] output_init = [] # time.sleep(20) # what is going on? # just to check. # it is working, after all. # may miss a bit? # you should get that thing! # no error! strange thing! # there should be error. # no respond! how about python? # why you have to wait # sleep for a while? timeall = 1000 charlen_buff = 40000 time_limit = 10 # will be problem. # computer is gonna blow. # this will be incredible. # time precision. # we are gonna count. counter = 0 patience = 5 # is it too much? # self-related? # only one shot? no reattaching? no anything convoluted? jam_warn = False global_buff = "" while timeall >= 0 and patience > 0 and charlen_buff > 0 and time.time( ) - timestamp < time_limit and not jam_warn: # i want to see some web repl. # always logic mistakes. so there should be alternative? #result = stdout.read() # while not stdout.channel.exit_status_ready(): # # Only print data if there is data to read in the channel # if stdout.channel.recv_ready(): # rl, wl, xl = select.select([stdout.channel], [], [], 0.0) # if len(rl) > 0: # Print data from stdout # print(stdout.channel.recv(1024),) # this is not good. # if not result: # search for possible errors! # errors are sweet? # it is all connected. # does the order matters? # print(output.decode()) try: # p = timeout(0.1)(output.decode) p = timeout(1)(remote_conn.recv) # we are missing things. x = p(1000).decode() if len(x) > 135: if ajam(x, 75, 0.7, 500, 0.3): jam_warn = True break global_buff += x # total counts? # anyway, hope this works. # there could be limit. # dynamic things? if ajam(global_buff, 75, 0.7, 500, 0.3): jam_warn = True break # if highly repetitive, break. # decode? output_init.append([x, counter, time.time()]) # print(x) charlen_buff -= len(x) counter += 1 # it is shit. # but then we get stuck. except: # print(traceback.format_exc()) patience -= 1 # there is no error. pass # well, for those non-ending. # code is intepretable for shell but no unicode support? # print(output) # what is the color? # check it? # time.sleep(0.1) # print(timeall, time.time()-timestamp) # it is likely to fail. timeall -= 1 # do we really know it is repl? # never mind. we can do manual debugging from now on. # result = stderr.read() # timestamp? # a highighter will be useful. ssh.close() # just return? # initial # print(output_init) return (stdt, a, output_init)
if __name__ == "__main__": port = "5599" context = zmq.Context() socket = context.socket(zmq.PAIR) socket.bind("tcp://127.0.0.17:%s" % port) # print("bind") # socket.send_string("Hello World!") # print("sent") # socket.RCVTIMEO=1 # f**k. # not even working at this point. while True: # what the f**k is this? try: msg = timeout(1)(socket.recv_pyobj) print("f**k") msg = msg(flags=zmq.NOBLOCK) # not working. # f*****g hell. print("f**k") print(msg) except: socket.send_string("heartbeat") print("sent") # will it work? # timeout this? # why sigsegv? # timestamp this? # send heartbeat packages? # will it stuck? # freeze_support()
import torch from sub2 import timeout xo = timeout(2)(torch.randn) # xo=xo((300,300,300,2)) # xo=xo((47,48,48,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[47, 48, 48, 48] to have 3 channels, but got 48 channels instead # xo=xo((48,47,48,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[48, 47, 48, 48] to have 3 channels, but got 47 channels instead # xo=xo((48,48,47,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[48, 48, 47, 48] to have 3 channels, but got 48 channels instead xo = xo((100, 3, 48, 48)) # xo=xo.stride() # print(dir(xo)) # this is used when it is flatterned. print(type(xo)) # print(xo.shape) # print(type(xo),xo) # Stride is the jump necessary to go from one element to the next one in the # specified dimension :attr:`dim`. A tuple of all strides is returned when no # argument is passed in. Otherwise, an integer value is returned as the stride in # the particular dimension :attr:`dim`.
from sub2 import timeout import torch.nn.functional as F # ????? # import functools # fit-in, fit-out, run. import numpy as np # it nearly kills me. # what the heck is going on? # what the heck is going on? def checkFlow(a): return a.in_channels, a.out_channels # what the heck is going on? # what the heck is going on? # moduledict? what the heck? # i'm gonna f**k. xo = timeout(2)(torch.randn) # xo=xo((300,300,300,2)) # xo=xo((47,48,48,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[47, 48, 48, 48] to have 3 channels, but got 48 channels instead # xo=xo((48,47,48,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[48, 47, 48, 48] to have 3 channels, but got 47 channels instead # xo=xo((48,48,47,48)) # RuntimeError: Given groups=1, weight of size [18, 3, 3, 3], expected input[48, 48, 47, 48] to have 3 channels, but got 48 channels instead xo = xo((100, 3, 48, 48)) # tensorflow will become another battlefield. # print(dir(xo)) # print(xo) # strange shit. # first for sample. # second for channels. # this is weird. magic.
# # Only print data if there is data to read in the channel # if stdout.channel.recv_ready(): # rl, wl, xl = select.select([stdout.channel], [], [], 0.0) # if len(rl) > 0: # Print data from stdout # print(stdout.channel.recv(1024),) # this is not good. # if not result: # search for possible errors! # errors are sweet? # it is all connected. # does the order matters? # print(output.decode()) try: # p = timeout(0.1)(output.decode) p = timeout(1)(remote_conn.recv) # we are missing things. x = p(1000).decode() output_init.append([x, counter, time.time()]) print(x) counter += 1 # it is shit. # but then we get stuck. except: # print(traceback.format_exc()) patience -= 1 # there is no error. pass # well, for those non-ending. # code is intepretable for shell but no unicode support? # print(output)