How to use run_cmd method in redwood

Best JavaScript code snippet using redwood

test_pymailq_shell.py

Source:test_pymailq_shell.py Github

copy

Full Screen

...35 for call in MOCK_STDOUT.write.call_args_list:36 res += call[0][0]37 MOCK_STDOUT.reset_mock()38 return res.strip()39def run_cmd(command):40 """Run command in shell41 :param str command: Shell command42 :return: Shell response as :func:`str`43 """44 PQSHELL.onecmd(command)45 return answer()46def test_shell_init():47 """Test shell.PyMailqShell object"""48 assert hasattr(PQSHELL, "cmdloop_nointerrupt")49 assert PQSHELL.prompt == "PyMailq (sel:0)> "50def test_shell_exit():51 """Test shell.PyMailqShell object"""52 PQSHELL.cmdqueue = ['exit']53 PQSHELL.cmdloop_nointerrupt()54 assert "Exiting shell... Bye." in answer()55def test_shell_empty_line():56 """Test empty line"""57 resp = run_cmd("")58 assert not len(resp)59def test_shell_completion():60 """Test shell completion"""61 resp = PQSHELL.completenames("sho")62 assert ["show "] == resp63 resp = PQSHELL.completedefault("invalid", "invalid")64 assert resp is None65 resp = PQSHELL.completedefault("re", "select re")66 assert ["recipient", "replay", "reset"] == sorted(resp)67 resp = PQSHELL.completedefault("sel", "show sel")68 assert ["selected"] == resp69 resp = PQSHELL.completedefault("", "show selected ")70 assert ["limit", "rankby", "sortby"] == sorted(resp)71 resp = PQSHELL.completedefault("",72 "show selected limit x rankby x sortby x")73 assert resp is None74 resp = PQSHELL.completedefault("", "show selected limit ")75 assert ["<n> "] == resp76 resp = PQSHELL.completedefault("", "show selected limit 5 ")77 assert ["rankby", "sortby"] == sorted(resp)78 resp = PQSHELL.completedefault("sen", "select sen")79 assert ["sender "] == resp80 resp = PQSHELL.completedefault("", "select sender ")81 assert ["<sender> [exact]"] == resp82def test_shell_help():83 """Test 'help' command"""84 resp = run_cmd("help")85 assert "Documented commands" in resp86def test_shell_help_help():87 """Test 'help help' command"""88 resp = run_cmd("help help")89 assert "Show available commands" in resp90def test_shell_help_exit():91 """Test 'help exit' command"""92 resp = run_cmd("help exit")93 assert "Exit PyMailq shell" in resp94def test_shell_help_show():95 """Test 'help show' command"""96 resp = run_cmd("help show")97 assert "Generic viewer utility" in resp98def test_shell_help_store():99 """Test 'help store' command"""100 resp = run_cmd("help store")101 assert "Control of Postfix queue content storage" in resp102def test_shell_help_select():103 """Test 'help select' command"""104 resp = run_cmd("help select")105 assert "Select mails from Postfix queue content" in resp106def test_shell_help_inspect():107 """Test 'help inspect' command"""108 resp = run_cmd("help inspect")109 assert "Mail content inspector" in resp110def test_shell_help_super():111 """Test 'help super' command"""112 resp = run_cmd("help super")113 assert "Call postsuper commands" in resp114def test_shell_store_status_unloaded():115 """Test 'store status' command with unloaded store"""116 resp = run_cmd("store status")117 assert "store is not loaded" in resp118def test_shell_store_load_error():119 """Test 'store load' command"""120 resp = run_cmd("store load notfound.txt")121 assert "*** Error: unable to load store" in resp122def test_shell_store_load():123 """Test 'store load' command"""124 resp = run_cmd("store load")125 assert "mails loaded from queue" in resp126def test_shell_store_status_loaded():127 """Test 'store status' command with loaded store"""128 resp = run_cmd("store status")129 assert "store loaded with " in resp130def test_shell_inspect_mails_not_found():131 resp = run_cmd("inspect mails XXXXXXXX")132 assert 'Mail IDs not found' in resp133def test_shell_inspect_mails():134 """Test 'inspect mails' command"""135 CONFIG['commands']['use_sudo'] = True136 qids = [mail.qid for mail in PQSHELL.pstore.mails[0:2]]137 resp = run_cmd("inspect mails %s %s" % (qids[0], qids[1]))138 assert qids[0] in resp139 assert qids[1] in resp140def test_shell_show():141 """Test 'show' command without arguments"""142 resp = run_cmd("show")143 assert "Generic viewer utility" in resp144def test_shell_show_invalid():145 """Test 'show invalid' command"""146 resp = run_cmd("show invalid")147 assert "*** Syntax error: show invalid" in resp148 resp = run_cmd("show selected limit invalid")149 assert "*** Syntax error: limit modifier needs a valid number" in resp150 resp = run_cmd("show selected rankby")151 assert "*** Syntax error: rankby requires a field" in resp152 resp = run_cmd("show selected rankby invalid")153 assert "*** Syntax error: elements cannot be ranked by" in resp154 resp = run_cmd("show selected sortby")155 assert "*** Syntax error: sortby requires a field" in resp156 resp = run_cmd("show selected sortby invalid")157 assert "*** Syntax error: elements cannot be sorted by" in resp158def test_shell_show_selected_limit():159 """Test 'show selected limit 2' command"""160 resp = run_cmd("show selected limit 2")161 assert "Preview of first 2" in resp162 assert len(resp.split('\n')) == 3163 resp = run_cmd("show selected limit 10000")164 assert "Preview of first 10000" not in resp165 assert len(resp.split('\n')) == 500166def test_shell_show_selected_sorted():167 """Test 'show selected sortby sender limit 2' command"""168 resp = run_cmd("show selected sortby sender asc limit 2")169 assert "Preview of first 2" in resp170 assert len(resp.split('\n')) == 3171 resp = run_cmd("show selected sortby sender desc limit 2")172 assert "Preview of first 2" in resp173 assert len(resp.split('\n')) == 3174def test_shell_show_selected_rankby():175 """Test 'show selected rankby' command"""176 resp = run_cmd("show selected rankby sender limit 2")177 assert "sender" in resp178 assert len(resp.split('\n')) == 5179def test_shell_show_selected_long_format():180 """Test 'show selected format' command"""181 resp = run_cmd("show selected limit 2 long")182 assert len(resp.split('\n')) == 7183def test_shell_show_filters_empty():184 """Test 'show filters' command without registered filters"""185 resp = run_cmd("show filters")186 assert "No filters applied on current selection" in resp187def test_shell_select():188 """Test 'select' command"""189 resp = run_cmd("select")190 assert "Select mails from Postfix queue content" in resp191def test_shell_select_sender():192 """Test 'select sender' command"""193 assert 'Selector resetted' in run_cmd("select reset")194 assert not len(run_cmd("select sender sender-1"))195 resp = run_cmd("show selected")196 assert "sender-1@" in resp197 assert len(resp.split('\n')) == 100198 assert 'Selector resetted' in run_cmd("select reset")199 assert not len(run_cmd("select sender sender-1 exact"))200 resp = run_cmd("show selected")201 assert "No element to display" in resp202 resp = run_cmd("select sender sender-1 invalid")203 assert "invalid keyword: invalid" in resp204def test_shell_select_recipient():205 """Test 'select recipient' command"""206 assert 'Selector resetted' in run_cmd("select reset")207 assert not len(run_cmd("select recipient user-1"))208 resp = run_cmd("show selected")209 assert len(resp.split('\n')) == 100210 assert 'Selector resetted' in run_cmd("select reset")211 assert not len(run_cmd("select recipient user-1 exact"))212 resp = run_cmd("show selected")213 assert "No element to display" in resp214 resp = run_cmd("select recipient user-1 invalid")215 assert "invalid keyword: invalid" in resp216def test_shell_select_invalid():217 """Test 'select invalid' command"""218 resp = run_cmd("select invalid")219 assert "has no subcommand:" in resp220def test_shell_select_qids():221 """Test 'select qids' command"""222 assert 'mails loaded from queue' in run_cmd("store load")223 assert 'Selector resetted with store content' in run_cmd("select reset")224 qids = [mail.qid for mail in PQSHELL.pstore.mails[0:2]]225 resp = run_cmd("select qids %s %s" % (qids[0], qids[1]))226 assert not len(resp)227 assert len(PQSHELL.selector.mails) == 2228def test_shell_select_status():229 """Test 'select status' command"""230 resp = run_cmd("select status deferred")231 assert not len(resp)232def test_shell_select_size():233 """Test 'select size' command"""234 resp = run_cmd("select size XXX")235 assert "specified sizes must be valid numbers" in resp236 resp = run_cmd("select size 262 262")237 assert "exact size must be used alone" in resp238 resp = run_cmd("select size +262 +262")239 assert "multiple min sizes specified" in resp240 resp = run_cmd("select size -262 -262")241 assert "multiple max sizes specified" in resp242 resp = run_cmd("select size -263 +266")243 assert "minimum size is greater than maximum size" in resp244 assert 'mails loaded from queue' in run_cmd("store load")245 assert 'Selector resetted with store content' in run_cmd("select reset")246 assert not len(run_cmd("select size 1000"))247 resp = run_cmd("show selected")248 assert "No element to display" in resp249 assert 'Selector resetted with store content' in run_cmd("select reset")250 assert not len(run_cmd("select size +200"))251 resp = run_cmd("show selected")252 assert len(resp.split("\n")) == 500253 assert 'Selector resetted with store content' in run_cmd("select reset")254 assert not len(run_cmd("select size -1000"))255 resp = run_cmd("show selected")256 assert len(resp.split("\n")) == 250257 assert 'Selector resetted with store content' in run_cmd("select reset")258 assert not len(run_cmd("select size +200 -1000"))259 resp = run_cmd("show selected")260 assert len(resp.split("\n")) == 250261def test_shell_select_date():262 """Test 'select date' command"""263 five_days = timedelta(5)264 now = datetime.now().strftime('%Y-%m-%d')265 five_days_ago = (datetime.now() - five_days).strftime('%Y-%m-%d')266 in_five_days = (datetime.now() + five_days).strftime('%Y-%m-%d')267 assert 'mails loaded from queue' in run_cmd("store load")268 assert 'Selector resetted with store content' in run_cmd("select reset")269 assert not len(run_cmd("select date %s" % now))270 resp = run_cmd("show selected")271 assert len(resp.split("\n")) == 500272 assert 'Selector resetted with store content' in run_cmd("select reset")273 assert not len(run_cmd("select date %s" % five_days_ago))274 resp = run_cmd("show selected")275 assert "No element to display" in resp276 assert 'Selector resetted with store content' in run_cmd("select reset")277 assert not len(run_cmd("select date +%s" % five_days_ago))278 resp = run_cmd("show selected")279 assert len(resp.split("\n")) == 500280 assert 'Selector resetted with store content' in run_cmd("select reset")281 assert not len(run_cmd("select date +%s" % in_five_days))282 resp = run_cmd("show selected")283 assert "No element to display" in resp284 assert 'Selector resetted with store content' in run_cmd("select reset")285 assert not len(run_cmd("select date %s..%s" % (five_days_ago,286 in_five_days)))287 resp = run_cmd("show selected")288 assert len(resp.split("\n")) == 500289 assert 'Selector resetted with store content' in run_cmd("select reset")290 assert not len(run_cmd("select date -%s" % in_five_days))291 resp = run_cmd("show selected")292 assert len(resp.split("\n")) == 500293 resp = run_cmd("select date XXXX-XX-XX")294 assert "'XXXX-XX-XX' does not match format '%Y-%m-%d'" in resp295def test_shell_select_error():296 """Test 'select date' command"""297 assert 'mails loaded from queue' in run_cmd("store load")298 assert 'Selector resetted with store content' in run_cmd("select reset")299 assert not len(run_cmd("select error 'Test error message'"))300 resp = run_cmd("show selected")301 assert len(resp.split("\n")) == 16302def test_shell_show_filters():303 """Test 'show filters' command with registered filters"""304 assert 'Selector resetted with store content' in run_cmd("select reset")305 assert not len(run_cmd("select status deferred"))306 expected = ("0: select status:\n"307 " status: deferred")308 resp = run_cmd("show filters")309 assert expected == resp310def test_shell_select_replay():311 """Test 'select replay' command"""312 resp = run_cmd("select replay")313 assert "Selector resetted and filters replayed" in resp314def test_shell_select_rmfilter():315 """Test 'select rmfilter' command"""316 resp = run_cmd("select rmfilter 0")317 assert not len(resp)318 resp = run_cmd("select rmfilter 666")319 assert "invalid filter ID: 666" in resp320def test_shell_select_reset():321 """Test 'select reset' command"""322 resp = run_cmd("select reset")323 assert "Selector resetted with store content" in resp324def test_shell_super_unloaded_or_no_selection():325 """Test QueueControl with an unloaded store"""326 loaded_at = PQSHELL.pstore.loaded_at327 setattr(PQSHELL.pstore, 'loaded_at', None)328 resp = run_cmd("super hold")329 assert 'The store is not loaded' in resp330 setattr(PQSHELL.pstore, 'loaded_at', loaded_at)331 setattr(PQSHELL.selector, 'mails', [])332 resp = run_cmd("super hold")333 assert 'No mail selected' in resp334 run_cmd("select reset")335def test_shell_super_hold():336 """Test 'select reset' command"""337 CONFIG['commands']['use_sudo'] = True338 resp = run_cmd("super hold")339 assert "postsuper: Placed on hold" in resp340def test_shell_super_release():341 """Test 'select reset' command"""342 CONFIG['commands']['use_sudo'] = True343 resp = run_cmd("super release")344 assert "postsuper: Released" in resp345def test_shell_super_requeue():346 """Test 'super requeue' command"""347 CONFIG['commands']['use_sudo'] = True348 resp = run_cmd("super requeue")349 assert "postsuper: Requeued" in resp350def test_shell_super_delete():351 """Test 'select reset' command"""352 CONFIG['commands']['use_sudo'] = True353 resp = run_cmd("super delete")...

Full Screen

Full Screen

blt.js

Source:blt.js Github

copy

Full Screen

...74 resolve(sum/count)75 });76}77exports.getCommand = (cmd_key) => cmd_replacer(cmd_key)78exports.db_stop = () => run_cmd(commands.db_stop)79exports.db_start = () => run_cmd(commands.db_start)80exports.sdb_go = () => run_cmd(commands.sdb_go)81exports.restartBlt = () => run_cmd(commands.restart_blt)82exports.sync_blt = () => run_cmd(commands.sync_blt)83exports.build_blt = () => run_cmd(commands.build_blt)84exports.build_pre_blt = () => run_cmd(commands.build_pre_blt)85exports.ide_blt = () => run_cmd(commands.ide_blt)86exports.enable_blt = () => run_cmd(commands.enable_blt)87exports.disable_blt = () => run_cmd(commands.disable_blt)88exports.start_blt = () => run_cmd(commands.start_blt)89exports.stop_blt = () => run_cmd(commands.stop_blt)90exports.adventure_build = () => run_cmd(commands.adventure_build)91exports.enable_force = () => run_cmd(commands.enable_force)92// fast running commands use _cmd93exports.get_project_dirs = () => _cmd(commands.get_project_dirs)94exports.get_project_dir_status = () => _cmd(commands.get_project_dir_status)95exports.get_project = () => new Promise(resolve => resolve(projectDir))96exports.set_project = (dir) => new Promise(resolve => {97 working_dir = resolveHome(path.join("~", "blt", dir));98 projectDir = dir99 project = proj+projectDir100 working_dir_cmd = "cd " + working_dir + " && ";101 fs.writeFileSync(constants.projectFile,dir)102 resolve(working_dir)103})104exports.killblt = (timeout) => {105 if(timeout === undefined)...

Full Screen

Full Screen

test_phone_book.py

Source:test_phone_book.py Github

copy

Full Screen

...5@pytest.fixture6def no_db():7 with contextlib.suppress(Exception):8 os.unlink("directory.db")9def run_cmd(cmd):10 cmd = cmd.split()11 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)12 ret = p.wait()13 return ret, p.stdout.read().decode("ascii").strip()14def test_list_without_db(no_db):15 exit_status, op = run_cmd("./phone_book list")16 assert exit_status == 117 assert op == "Couldn't open database file: No such file or directory"18def test_search_without_db(no_db):19 exit_status, op = run_cmd("./phone_book search foo")20 assert exit_status == 121 assert op == "Couldn't open database file: No such file or directory"22def test_delete_without_db(no_db):23 exit_status, op = run_cmd("./phone_book delete foo")24 assert exit_status == 125 assert op == "Couldn't open database file: No such file or directory"26def test_adding_listing(no_db):27 exit_status, _ = run_cmd("./phone_book add john 1234567890")28 assert exit_status == 029 exit_status, _ = run_cmd("./phone_book add jack 0987654321")30 assert exit_status == 031 exit_status, _ = run_cmd("./phone_book add james 5432167890")32 assert exit_status == 033 exit_status, op = run_cmd("./phone_book list")34 assert exit_status == 035 expected = """john : 123456789036jack : 098765432137james : 543216789038Total entries : 3"""39 assert (op == expected)40def test_adding_searching_found(no_db):41 exit_status, _ = run_cmd("./phone_book add john 1234567890")42 assert exit_status == 043 exit_status, _ = run_cmd("./phone_book add jack 0987654321")44 assert exit_status == 045 exit_status, _ = run_cmd("./phone_book add james 5432167890")46 assert exit_status == 047 exit_status, op = run_cmd("./phone_book search john")48 assert exit_status == 049 expected = "1234567890"50 assert (op == expected)51def test_adding_searching_notfound(no_db):52 exit_status, _ = run_cmd("./phone_book add john 1234567890")53 assert exit_status == 054 exit_status, _ = run_cmd("./phone_book add jack 0987654321")55 assert exit_status == 056 exit_status, _ = run_cmd("./phone_book add james 5432167890")57 assert exit_status == 058 exit_status, op = run_cmd("./phone_book search wick")59 assert exit_status == 160 expected = "no match"61 assert (op == expected)62def test_adding_deleting_nonexistent(no_db):63 exit_status, _ = run_cmd("./phone_book add john 1234567890")64 assert exit_status == 065 exit_status, _ = run_cmd("./phone_book add jack 0987654321")66 assert exit_status == 067 exit_status, _ = run_cmd("./phone_book add james 5432167890")68 assert exit_status == 069 exit_status, op = run_cmd("./phone_book delete wick")70 assert exit_status == 171 expected = "no match"72 assert (op == expected)73def test_adding_deleting_first_list(no_db):74 exit_status, _ = run_cmd("./phone_book add john 1234567890")75 assert exit_status == 076 exit_status, _ = run_cmd("./phone_book add jack 0987654321")77 assert exit_status == 078 exit_status, _ = run_cmd("./phone_book add james 5432167890")79 assert exit_status == 080 exit_status, op = run_cmd("./phone_book delete john")81 assert exit_status == 082 exit_status, op = run_cmd("./phone_book list")83 assert exit_status == 084 expected = """jack : 098765432185james : 543216789086Total entries : 2"""87 assert (op == expected)88 89def test_adding_deleting_middle_list(no_db):90 exit_status, _ = run_cmd("./phone_book add john 1234567890")91 assert exit_status == 092 exit_status, _ = run_cmd("./phone_book add jack 0987654321")93 assert exit_status == 094 exit_status, _ = run_cmd("./phone_book add james 5432167890")95 assert exit_status == 096 exit_status, op = run_cmd("./phone_book delete jack")97 assert exit_status == 098 exit_status, op = run_cmd("./phone_book list")99 assert exit_status == 0100 expected = """john : 1234567890101james : 5432167890102Total entries : 2"""103 assert (op == expected)104 105def test_valgrind(no_db):106 run_cmd("./phone_book add john 1234567890")107 run_cmd("./phone_book add jack 0987654321")108 run_cmd("./phone_book add james 5432167890")109 exit_status, op = run_cmd("valgrind ./phone_book list")110 assert "All heap blocks were freed -- no leaks are possible" in op, "Memory is not being properly freed"111 112 ...

Full Screen

Full Screen

setup_network_config.py

Source:setup_network_config.py Github

copy

Full Screen

...4from subprocess import PIPE5import sys6args = sys.argv7malware_repository_ipaddr = args[1]8def run_cmd(cmd):9 proc = subprocess.run(cmd, shell=True, stdout=PIPE, stderr=PIPE)10 return proc11run_cmd("sudo iptables -N userchain_forward")12run_cmd("sudo iptables -A userchain_forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT")13run_cmd("sudo iptables -A userchain_forward -i mybridge -o eth0 -j ACCEPT")14run_cmd("sudo iptables -I FORWARD 1 -j userchain_forward")15run_cmd("sudo iptables -I userchain_forward -p tcp --dport 23 -j DROP")16run_cmd("sudo iptables -I userchain_forward -p udp --dport 23 -j DROP")17run_cmd("sudo iptables -I userchain_forward -p tcp --dport 2323 -j DROP")18run_cmd("sudo iptables -I userchain_forward -p udp --dport 2323 -j DROP")19#iptables input20run_cmd("sudo iptables -N userchain_input")21run_cmd("sudo iptables -I userchain_input -p udp --dport 67 -i mybridge -j ACCEPT")22run_cmd("sudo iptables -I userchain_input -p udp --dport 53 -s 172.20.0.0/16 -j ACCEPT")23run_cmd("sudo iptables -I userchain_input -p tcp --dport 53 -s 172.20.0.0/16 -j ACCEPT")24run_cmd("sudo iptables -I INPUT 1 -j userchain_input")25run_cmd("sudo iptables -I userchain_input -p tcp --dport 23 -j DROP")26run_cmd("sudo iptables -I userchain_input -p udp --dport 23 -j DROP")27run_cmd("sudo iptables -I userchain_input -p tcp --dport 2323 -j DROP")28run_cmd("sudo iptables -I userchain_input -p udp --dport 2323 -j DROP")29## This is to suppress the excessive access to port 23 (telnet) that could be caused by Mirai.30run_cmd("iptables -I INPUT -p tcp -i mybridge --syn --dport 23 -m connlimit --connlimit-above 5 -j REJECT")31proc = subprocess.run(["pgrep", "-f", "dnsmasq"], stdout=PIPE, stderr=PIPE)32dnsmasq_pid = proc.stdout.decode("utf-8")33if len(dnsmasq_pid) > 0:34 run_cmd("pgrep -f dnsmasq | xargs sudo kill -KILL")35run_cmd("sudo brctl addbr mybridge")36run_cmd("sudo ip link set mybridge up")37run_cmd("sudo dnsmasq --interface=mybridge --bind-interfaces --dhcp-range=172.20.222.2,172.20.222.254")38run_cmd("sudo ip addr add 172.20.0.1/16 dev mybridge")39run_cmd("sudo ip tuntap add mode tap vport1 user shun")40run_cmd("sudo brctl addif mybridge vport1")41run_cmd("sudo ifconfig vport1 promisc up")42run_cmd("sudo ip tuntap add mode tap vport2 user shun")43run_cmd("sudo brctl addif mybridge vport2")44run_cmd("sudo ifconfig vport2 promisc up")45run_cmd("sudo iptables -t nat -I POSTROUTING -o mybridge -j MASQUERADE")46# 172.20.222.xxx (Sandbox machine is at 172.20.222.240), redirect to fakedns47run_cmd("sudo iptables -t nat -I PREROUTING -i mybridge -p udp --dport 53 -j DNAT -s 172.20.222.0/24 --to 172.20.100.100:53")48run_cmd("sudo iptables -t nat -I PREROUTING -i mybridge -p tcp --dport 8000 -j DNAT -s 172.20.222.0/24 --to {}:8000".format(malware_repository_ipaddr))49run_cmd("sudo iptables -A INPUT -p tcp --syn -m state --state NEW --dport 8000 -m limit --limit 4/m --limit-burst 4 -j ACCEPT")50run_cmd("sudo iptables -A INPUT -p tcp --syn -m state --state NEW --dport 8000 -j DROP")51activated_port = [21, 22, 23, 25, 443, 990, 1, 995, 37, 7, 9, 6667, 13, 2222, 110, 2223, 79, 80, 2224, 465, 17, 113, 19]52for i in activated_port:53 comm = "sudo iptables -t nat -I PREROUTING -i mybridge -p tcp --dport {port} -j DNAT -s 172.20.222.0/24 --to 172.20.100.100:{port}".format(port=i)54 run_cmd(comm)55#Use "-A" option to add new rule at the end of the chain. As for destination ports from 1 to 65535 that are not set above, direct them to an arbitrary port, 6667 or IRC.56run_cmd("sudo iptables -A PREROUTING -t nat -i mybridge -p tcp --dport 1:65535 -j DNAT --to-destination 172.20.100.100:6667")57#dns setting (backup)...

Full Screen

Full Screen

runner.js

Source:runner.js Github

copy

Full Screen

1var shell = require('shelljs');2const shortid = require('shortid');3const Airtable = require('airtable');4const puppeteer = require('puppeteer');5var base = new Airtable({apiKey: process.env.AIRTABLE_API_KEY}).base(process.env.MEDIATER_BASE_ID);6// var base = new Airtable({apiKey: ''}).base(''); // Add mine here the revert while pushing 7async function launcher() {8 filter_formula = 'AND({Animated} = "Static")';9 await base('am_JaspPayload').select({10 // set maxRecords 1 for testing11 // maxRecords: 5,12 filterByFormula: filter_formula13 // }).firstPage(async function(err, records) {14 // }).eachPage(function page(records, fetchNextPage) {15 }).all().then(records => {16 // if (err) { console.error(err); return; }17 records.forEach(async function(record) {18 // console.log(record);19 // console.log(record.id);20 // console.log(record.get("jasp_info_element"));21 // console.log(record.get("jasp_info_url"));22 recordId = record.id;23 var producerRec = "";24 if (record.get("CovidFeedUSA_Producer") != undefined){25 producerRec = record.get("CovidFeedUSA_Producer")[0]; //Note - only pulls 1st connected record, in case multiple then will need to update this code26 }27 var run_cmd = ""28 if (record.get("jasp_info_element")) {29 run_cmd = "node index.js -u \"" + record.get("jasp_info_url") + "\" -e \"" + record.get("jasp_info_element") + "\"";30 }31 else {32 run_cmd = "node index.js -u \"" + record.get("jasp_info_url") + "\"";33 }34 if (record.get("view_type") == "mobile") {35 run_cmd = run_cmd + " -w \"" + record.get("dimension - width") + "\"";36 }37 // console output because otherwise travis fails after 10 minutes.38 run_cmd = run_cmd + " -r \"" + record.id + "\"";39 if (producerRec != ""){40 run_cmd = run_cmd + " -p \"" + producerRec + "\"";41 }42 if (record.get("blocker_element")) {43 run_cmd = run_cmd + " -b \"" + record.get("blocker_element") + "\"";44 }45 console.log(run_cmd);46 // Run external tool synchronously47 if (shell.exec(run_cmd).code !== 0) {48 shell.echo('Error: node command failed');49 shell.exit(1);50 }51 });52 // fetchNextPage();53 }, function done(err) {54 if (err) { console.error(err); return; }55 if (shell.exec("zip -r screenshots.zip screenshots/").code !== 0) {56 shell.echo('Error: zip command failed');57 shell.exit(1);58 }59 if (shell.exec("cp screenshots.zip /tmp/.").code !== 0) {60 shell.echo('Error: zip copy command failed');61 shell.exit(1);62 }63 });64};...

Full Screen

Full Screen

command.py

Source:command.py Github

copy

Full Screen

1import os2from flask import Blueprint, request3command = Blueprint('cmd', __name__, url_prefix='/cmd')4"""5␣ ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] { | }6%20 %21 %22 %23 %24 %25 %26 %27 %28 %29 %2A %2B %2C %2D %2E %2F %3A %3B %3C %3D %3E %3F %40 %5B %5C %5D %7B %7C %7D7https://de.wikipedia.org/wiki/URL-Encoding#Relevante_ASCII-Zeichen_in_Prozentdarstellung8"""9@command.route('/run')10def cmd():11 run_cmd = request.args.get('cmd', None)12 try:13 run_cmd = run_cmd.replace('%20', ' ')14 except:15 pass16 try:17 run_cmd = run_cmd.replace('%20', ' ')18 except:19 pass20 try:21 run_cmd = run_cmd.replace('%21', '!')22 except:23 pass24 try:25 run_cmd = run_cmd.replace('%22', '"')26 except:27 pass28 try:29 run_cmd = run_cmd.replace('%23', '#')30 except:31 pass32 try:33 run_cmd = run_cmd.replace('%24', '$')34 except:35 pass36 try:37 run_cmd = run_cmd.replace('%25', '%')38 except:39 pass40 try:41 run_cmd = run_cmd.replace('%26', '&')42 except:43 pass44 try:45 run_cmd = run_cmd.replace('%27', "'")46 except:47 pass48 try:49 run_cmd = run_cmd.replace('%28', '(')50 except:51 pass52 try:53 run_cmd = run_cmd.replace('%29', ')')54 except:55 pass56 try:57 run_cmd = run_cmd.replace('%2A', '*')58 except:59 pass60 try:61 run_cmd = run_cmd.replace('%2B', '+')62 except:63 pass64 try:65 run_cmd = run_cmd.replace('%2C', ',')66 except:67 pass68 try:69 run_cmd = run_cmd.replace('%2D', '-')70 except:71 pass72 try:73 run_cmd = run_cmd.replace('%2E', '.')74 except:75 pass76 try:77 run_cmd = run_cmd.replace('%2F', '/')78 except:79 pass80 try:81 run_cmd = run_cmd.replace('%3A', ':')82 except:83 pass84 try:85 run_cmd = run_cmd.replace('%3B', ';')86 except:87 pass88 try:89 run_cmd = run_cmd.replace('%3C', '<')90 except:91 pass92 try:93 run_cmd = run_cmd.replace('%3D', '=')94 except:95 pass96 try:97 run_cmd = run_cmd.replace('%3E', '>')98 except:99 pass100 try:101 run_cmd = run_cmd.replace('%3F', '?')102 except:103 pass104 try:105 run_cmd = run_cmd.replace('%40', '@')106 except:107 pass108 try:109 run_cmd = run_cmd.replace('%5B', '[')110 except:111 pass112 try:113 run_cmd = run_cmd.replace('%5C', '\\')114 except:115 pass116 try:117 run_cmd = run_cmd.replace('%5D', ']')118 except:119 pass120 try:121 run_cmd = run_cmd.replace('%7B', '{')122 except:123 pass124 try:125 run_cmd = run_cmd.replace('%7C', '|')126 except:127 pass128 try:129 run_cmd = run_cmd.replace('%7D', '}')130 except:131 pass132 os.system(run_cmd)...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1var shell = require('shelljs');2const shortid = require('shortid');3const Airtable = require('airtable');4const puppeteer = require('puppeteer');5var base = new Airtable({apiKey: process.env.AIRTABLE_API_KEY}).base(process.env.MEDIATER_BASE_ID);6async function launcher() {7 filter_formula = 'AND({Animated} = "Static")';8 await base('am_Embed').select({9 // set maxRecords 1 for testing10 // maxRecords: 1,11 filterByFormula: filter_formula12 }).eachPage(function page(records, fetchNextPage) {13 // if (err) { console.error(err); return; }14 records.forEach(async function(record) {15 // console.log(record);16 // console.log(record.id);17 // console.log(record.get("jasp_info_element"));18 // console.log(record.get("jasp_info_url"));19 recordId = record.id;20 console.log(recordId);21 console.log(record.get("jasp_info_url"));22 console.log(record.get("jasp_info_element"));23 await base('am_Embed').find(recordId, async function(err, record) {24 if (err) { console.error(err); return; }25 console.log('Retrieved ', record.id);26 });27 console.log("--------------------------------")28 // var run_cmd = ""29 // if (record.get("jasp_info_element")) {30 // run_cmd = "node index.js -u \"" + record.get("jasp_info_url") + "\" -e \"" + record.get("jasp_info_element") + "\"";31 // }32 // else {33 // run_cmd = "node index.js -u \"" + record.get("jasp_info_url") + "\"";34 // }35 // if (record.get("view_type") == "mobile") {36 // run_cmd = run_cmd + " -w \"" + record.get("dimension - width") + "\"";37 // }38 // // console output because otherwise travis fails after 10 minutes.39 // console.log(run_cmd);40 // run_cmd = run_cmd + " -r \"" + record.id + "\"";41 // // Run external tool synchronously42 // if (shell.exec(run_cmd).code !== 0) {43 // shell.echo('Error: node command failed');44 // shell.exit(1);45 // }46 });47 fetchNextPage();48 // if (shell.exec("zip -r screenshots.zip screenshots/").code !== 0) {49 // shell.echo('Error: zip command failed');50 // shell.exit(1);51 // }52 // if (shell.exec("cp screenshots.zip /tmp/.").code !== 0) {53 // shell.echo('Error: zip copy command failed');54 // shell.exit(1);55 // }56 }, function done(err) {57 if (err) { console.error(err); return; }58 console.log("DONE DONE");59 });60};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2redwood.run_cmd('ls -l', function (err, data) {3 if (err) {4 console.log(err);5 }6 console.log(data);7});8var redwood = require('redwood');9redwood.run_cmd('ls -l', function (err, data) {10 if (err) {11 console.log(err);12 }13 console.log(data);14});15var redwood = require('redwood');16redwood.run_cmd('ls -l', function (err, data) {17 if (err) {18 console.log(err);19 }20 console.log(data);21});22var redwood = require('redwood');23redwood.run_cmd('ls -l', function (err, data) {24 if (err) {25 console.log(err);26 }27 console.log(data);28});29var redwood = require('redwood');30redwood.run_cmd('ls -l', function (err, data) {31 if (err) {32 console.log(err);33 }34 console.log(data);35});36var redwood = require('redwood');37redwood.run_cmd('ls -l', function (err, data) {38 if (err) {39 console.log(err);40 }41 console.log(data);42});43var redwood = require('redwood');44redwood.run_cmd('ls -l', function (err, data) {45 if (err) {46 console.log(err);47 }48 console.log(data);49});50var redwood = require('redwood');51redwood.run_cmd('ls -l', function (err, data) {52 if (err) {53 console.log(err);54 }55 console.log(data);56});57var redwood = require('redwood');58redwood.run_cmd('ls -l', function (err, data) {59 if (err) {60 console.log(err);61 }62 console.log(data);63});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var run_cmd = redwood.run_cmd;3var run = run_cmd('ls', ['-l']);4run.stdout.on('data', function(data) {5 console.log('stdout: ' + data);6});7run.stderr.on('data', function(data) {8 console.log('stderr: ' + data);9});10run.on('exit', function(code) {11 console.log('child process exited with code ' + code);12});13var redwood = require('redwood');14var run_cmd = redwood.run_cmd;15var run = run_cmd('ls', ['-l']);16run.stdout.on('data', function(data) {17 console.log('stdout: ' + data);18});19run.stderr.on('data', function(data) {20 console.log('stderr: ' + data);21});22run.on('exit', function(code) {23 console.log('child process exited with code ' + code);24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var run_cmd = redwood.run_cmd;3run_cmd('ls', ['-l'], function(text) {4 console.log(text);5});6var redwood = require('redwood');7var run_cmd = redwood.run_cmd;8run_cmd('ls', ['-l'], function(text) {9 console.log(text);10});11var redwood = require('redwood');12var run_cmd = redwood.run_cmd;13run_cmd('ls', ['-l'], function(text) {14 console.log(text);15});16var redwood = require('redwood');17var run_cmd = redwood.run_cmd;18run_cmd('ls', ['-l'], function(text) {19 console.log(text);20});21var redwood = require('redwood');22var run_cmd = redwood.run_cmd;23run_cmd('ls', ['-l'], function(text) {24 console.log(text);25});26var redwood = require('redwood');27var run_cmd = redwood.run_cmd;28run_cmd('ls', ['-l'], function(text) {29 console.log(text);30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var options = {3};4redwood.run_cmd(options, function (err, data) {5 console.log(data);6});7function (err, data) {8}

Full Screen

Using AI Code Generation

copy

Full Screen

1var run_cmd = require('redwood').run_cmd;2run_cmd('ls', ['-lh', '/usr'], function (text) { 3 console.log(text);4});5module.exports.run_cmd = function(cmd, args, callback) {6 var spawn = require('child_process').spawn;7 var child = spawn(cmd, args);8 var resp = "";9 child.stdout.on('data', function (buffer) { resp += buffer.toString(); });10 child.stdout.on('end', function() { callback (resp) });11};12var spawn = require('child_process').spawn;13var child = spawn('ls', ['-lh', '/usr']);14child.stdout.on('data', function (buffer) { console.log(buffer.toString()); });15child.stdout.on('end', function() { console.log('end'); });16var spawn = require('child_process').spawn;17var child = spawn('ls', ['-lh', '/usr'], { stdio: 'inherit' });18I have a requirement to execute a command from a nodejs script. I am trying to use the child_process.spawn method to execute the command. It works fine when I execute the command interactively from the shell. But when I execute the same command from the nodejs script, it does not work. I get the following error: Error: spawn ENOENT The code that I am using is as follows: var spawn = require('child_process').spawn; var child = spawn('ls', ['-lh', '/usr']); child.stdout.on('data', function (buffer) { console.log(buffer.toString()); }); child.stdout.on('end', function() { console.log('end'); }); I have also tried the following code: var spawn = require('child_process').spawn; var child = spawn('ls', ['-lh', '/usr'], { stdio: 'inherit' }); But I get

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var path = require('path');3var test = redwood.test;4var test1 = function() {5 var cmd = path.join(__dirname, 'test.sh');6 var options = {7 };8 redwood.run_cmd(cmd, options, function(err, result) {9 if (err) {10 test.fail('Error running test.sh');11 } else {12 test.pass('test.sh ran successfully');13 }14 });15};16var test2 = function() {17 var cmd = path.join(__dirname, 'test.sh');18 var options = {19 env: {20 }21 };22 redwood.run_cmd(cmd, options, function(err, result) {23 if (err) {24 test.fail('Error running test.sh');25 } else {26 test.pass('test.sh ran successfully');27 }28 });29};30var test3 = function() {31 var cmd = path.join(__dirname, 'test.sh');32 var options = {33 env: {34 },35 };36 redwood.run_cmd(cmd, options, function(err, result) {37 if (err) {38 test.fail('Error running test.sh');39 } else {40 test.pass('test.sh ran successfully');41 }42 });43};44var test4 = function() {45 var cmd = path.join(__dirname, 'test.sh');46 var options = {47 env: {48 },49 };50 redwood.run_cmd(cmd, options, function(err, result) {51 if (err) {52 test.fail('Error running test.sh');53 } else {54 test.pass('test.sh ran successfully');55 }56 });57};58var test5 = function() {59 var cmd = path.join(__dirname, 'test.sh');60 var options = {61 env: {62 },63 };

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 redwood 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