Browse Source

New random stuff

master
Julio Biason 5 years ago committed by Julio Biason
parent
commit
e0bd1e22ac
  1. 49
      dojo.py
  2. 19
      telinet.py

49
dojo.py

@ -0,0 +1,49 @@
def test():
_input = [100, 101, 102, 103, 104, 105, 110, 111, 112, 113, 114, 115, 150]
assert [[100, 105], [110, 115], [150]] == interval(_input)
def test_1():
_input = [100, 101, 102, 103, 104, 105, 110, 111, 112, 113, 114, 115]
assert [[100, 105], [110, 115]] == interval(_input)
def test_2():
_input = [100, 110, 111, 112, 113, 114, 115, 150]
assert [[100], [110, 115], [150]] == interval(_input)
def test_3():
_input = [100, 101, 102, 103, 104, 105, 107, 110, 111, 112, 113, 114, 115, 150]
assert [[100, 105], [107], [110, 115], [150]] == interval(_input)
def test_4():
assert [[100]] == interval([100])
def test_5():
assert [[1], [3], [5]] == interval([1, 3, 5])
def test_6():
assert [[1, 2]] == interval([1, 2])
def failure():
assert [[1]] == interval([1, 2])
def interval(data):
diffs = [(data[x] - data[x-1]) != 1
for x
in range(len(data))]
result = []
for value, _new in zip(data, diffs):
if _new:
result.append([value])
else:
result[-1] = [result[-1][0], value]
return result
if __name__ == "__main__":
test()
test_1()
test_2()
test_3()
test_4()
test_5()
test_6()
failure()

19
telinet.py

@ -0,0 +1,19 @@
import os, glob, telnetlib, time
CAMINHO = "/home/admin/deploy"
HOST = "127.0.0.1" # conecta no osgi do idempiere via localhost
PORT = 12612 # porta do osgi
TIMEOUT = 2
tn = telnetlib.Telnet(HOST, PORT, TIMEOUT)
# print("Open")
# tn.open(HOST, PORT)
print("ls")
tn.write("ls")
print("exit")
tn.write("exit")
tn.close()
print('Concluido')
Loading…
Cancel
Save