How to use push_path method in Slash

Best Python code snippet using slash

test_push.py

Source:test_push.py Github

copy

Full Screen

1import unittest2import sys3import os4import argparse5import unit.test_config as test_config6sys.path.append(os.path.join(os.path.dirname(__file__), '../../'))7from localize.commands import *8class TestPush (unittest.TestCase):9 def test_push_missing_token (self):10 push_path = os.getcwd() + '/unit/test_files/fr.json'11 config = {12 'api': {13 'project': test_config.project,14 test_config.environment: True,15 },16 'format': 'JSON',17 'push': {18 'sources': [19 { 'file' : push_path },20 ]21 },22 'type': 'phrase',23 }24 with self.assertRaises(KeyError):25 push(config)26 def test_push_missing_project (self):27 push_path = os.getcwd() + '/unit/test_files/fr.json'28 config = {29 'api': {30 'token': test_config.token,31 test_config.environment: True,32 },33 'format': 'JSON',34 'push': {35 'sources': [36 { 'file' : push_path },37 ]38 },39 'type': 'phrase',40 }41 with self.assertRaises(KeyError):42 push(config)43 def test_push_missing_file (self):44 config = {45 'api': {46 'project': test_config.project,47 'token': test_config.token,48 test_config.environment: True,49 },50 'format': 'JSON',51 'push': {52 'sources': [53 ]54 },55 'type': 'phrase',56 }57 with self.assertRaises(SystemExit) as SystemExitMessage:58 push(config)59 expected = 'Successfully pushed 0 file(s) to Localize'60 self.assertTrue(expected in SystemExitMessage.exception.args[0])61 62 def test_push_with_correct_data (self):63 push_path = os.getcwd() + '/unit/test_files/fr.json'64 config = {65 'api': {66 'project': test_config.project,67 'token': test_config.token,68 test_config.environment: True,69 },70 'format': 'JSON',71 'push': {72 'sources': [73 { 74 'file' : push_path,75 },76 ]77 },78 'type': 'phrase',79 }80 81 with self.assertRaises(SystemExit) as SystemExitMessage:82 push(config)83 expected = 'Successfully pushed 1 file(s) to Localize'...

Full Screen

Full Screen

push_so.py

Source:push_so.py Github

copy

Full Screen

...13 print(cmd)14 time.sleep(5)15 res = os.popen(cmd)16 return package in res.read()17def get_push_path(package):18 cmd = "adb shell pm path " + package19 print(cmd)20 res_path = os.popen(cmd)21 res_path_list = str.split(res_path.read().replace("\n", ""), "package:")22 res = res_path_list[1].split("base.apk")23 return res[0]24def push_so_file(so_path, push_path):25 cmd = "adb push " + so_path + " " + push_path + "lib/"26 print(cmd)27 res = os.popen(cmd)28 print(res.read())29 return res30def get_file_name(push_path):31 cmd = "adb shell ls " + push_path + "lib/"32 print(cmd)33 res = os.popen(cmd.replace("\n", ""))34 return res.read()35def change_file_name(push_path, old_file_name, new_file_name):36 cmd = "adb shell mv " + push_path + "lib/" + old_file_name + " " + push_path + "lib/" + new_file_name37 print(cmd)38 res = os.popen(cmd.replace("\n", ""))39 print(res.read())40 return res41if __name__ == "__main__":42 package = "com.taobao.tmoversea.android"43 apk_path = "D:\\GoogleAPK\\" + package + "\\base.apk"44 so_path = "D:\\GoogleAPK\\" + package + "\\split_config.armeabi_v7a\\lib"45 new_file_name = "arm"46 # print(check_apk(package))47 # install_apk(apk_path)48 # while True:49 # if check_apk(package):50 # break51 # else:52 # continue53 push_path = get_push_path(package)54 push_so_file(so_path, push_path)55 old_file_name = get_file_name(push_path)56 change_file_name(push_path, old_file_name, new_file_name)57# cmd = "adb shell mv /data/app/jp.co.cybird.appli.android.gen.ja-n4cnhhkeD0mBw0f8rVP4Gw==/lib/armeabi-v7a /data/app/jp.co.cybird.appli.android.gen.ja-n4cnhhkeD0mBw0f8rVP4Gw==/lib/arm"58# res = os.popen(cmd)...

Full Screen

Full Screen

push.cgi

Source:push.cgi Github

copy

Full Screen

1#!/usr/bin/env python32# vim:ts=4:sts=4:sw=4:expandtab3SECRET_PATH = 'github_secret'4PUSH_PATH = 'github_push'5BIN_PATH = 'bin/github_push'6import datetime7from multiprocessing import Process8import os9from pathlib import Path10import pwd11import subprocess12import sys13import tempfile14def result(code, status, body, exit=True):15 sys.stdout.write('Status: {} {}\r\n'.format(code, status))16 sys.stdout.write('Content-Length: {}\r\n'.format(len(body)))17 sys.stdout.write('\r\n')18 sys.stdout.write('{}'.format(body))19 if exit:20 sys.exit(0)21home = Path.home()22if not home.is_dir():23 home = Path(pwd.getpwuid(os.getuid()).pw_dir)24secret_path = home / SECRET_PATH25secret = ''26if not secret_path.is_file():27 result(500, 'Internal Server Error', 'FAIL')28with secret_path.open() as secret_file:29 secret = secret_file.read().strip()30if os.environ.get('QUERY_STRING','') != 'secret={}'.format(secret):31 result(403, 'Forbidden', 'FAIL')32if os.environ.get('REQUEST_METHOD','').upper() != 'POST':33 result(403, 'Forbidden', 'FAIL')34push_path = home / PUSH_PATH35push_path.mkdir(parents=True, exist_ok=True)36push_fd, push_path = tempfile.mkstemp(dir=str(push_path), prefix='{}_'.format(datetime.datetime.now().strftime('%Y%m%d%H%M%S')))37os.write(push_fd, sys.stdin.buffer.read())38os.close(push_fd)39result(200, 'OK', 'OK', exit=False)...

Full Screen

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