Skip to content

Instantly share code, notes, and snippets.

@dtmilano
dtmilano / android-select-device
Last active November 29, 2023 09:29
Script to select one connected device or emulator when running adb
#! /bin/bash
#=====================================================================
# Selects an android device
# Copyright (C) 2012-2022 Diego Torres Milano. All rights reserved.
#
# The simplest way to invoke this script is creating a function like
# this one in your shell startup file:
#
# ```
# adb ()
@dtmilano
dtmilano / gist:7426090
Created November 12, 2013 05:45
Jenkins command line plugin installation
/opt/jenkins/jenkins-cli install-plugin \
analysis-core \
android-emulator \
android-lint \
ant \
credentials \
cvs \
emmacoveragecolumn \
emma \
external-monitor-job \
@dtmilano
dtmilano / adb-emu-kill.exp
Last active November 17, 2016 16:10
`adb emu kill` does not work in latest `adb` versions. This is a workaround using `expect`.
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Wed Jun 29 12:07:46 2016
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import os
try:
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
@dtmilano
dtmilano / lex-bot-tester-sample.py
Created December 7, 2017 23:07
lex-bot-tester sample: AWS Lex Bot tester demonstration code
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Lex Bot Tester
Copyright (C) 2017 Diego Torres Milano
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@dtmilano
dtmilano / test_conversation_text_booj_car.py
Last active December 16, 2017 06:02
lex-bot-tester sample: Data oriented approach
def test_conversations_text_book_car(self):
bot_name = 'BookTrip'
bot_alias = 'BookTripLatest'
user_id = 'ClientId'
conversation_definition = {
'BookCar': [
('reserve a car', DialogState.ELICIT_SLOT, {}),
('L.A.', DialogState.ELICIT_SLOT, {}),
('next week', DialogState.ELICIT_SLOT, {'PickUpDate': RE_WEEK}),
('a month from now', DialogState.ELICIT_SLOT, {'ReturnDate': RE_DATE}),
@dtmilano
dtmilano / test_book_my_trip_reserve_a_car.py
Created January 23, 2018 16:46
Sample test showing an Alexa conversation for BookMyTripSkill
class AlexaSkillManagementClientTests(AlexaSkillTest):
def test_book_my_trip_reserve_a_car(self):
skill_name = 'BookMyTripSkill'
intent = 'BookCar'
conversation = [
{'slot': None, 'text': 'ask book my trip to reserve a car'},
{'slot': 'CarType', 'text': 'midsize'},
{'slot': 'PickUpCity', 'text': 'buenos aires'},
{'slot': 'PickUpDate', 'text': 'tomorrow'},
@dtmilano
dtmilano / plot_dumpsys_meminfo.py
Created January 25, 2018 04:35
Plots the dumpsys output using AndroidViewClient/culebra
def __plot_dumpsys_meminfo(self, pkg, activity, method=None):
self.device.shell("am force-stop %s" % pkg)
for n in range(20):
if n % 5 == 0:
self.device.shell(
"run-as %s pgrep -L 10 %s" % (pkg, pkg))
self.device.startActivity("%s/%s" % (pkg, activity))
time.sleep(2)
if method:
method()
@dtmilano
dtmilano / test_crypto_get_price.py
Created February 6, 2018 22:13
AlexaSkillManagementClientTests test for Crypto skill
class AlexaSkillManagementClientTests(AlexaSkillTest):
def test_crypto_get_price(self):
skill_name = 'CryptoSkill'
intent = 'GetPrice'
coin = 'Bitcoin'
conversation = [
{'slot': None, 'text': 'ask Crypto what is the {} price?'.format(coin)},
]
simulation_result = self.conversation_text(skill_name, intent, conversation, verbose=verbose)
self.assertRegex(
@dtmilano
dtmilano / test_book_my_trip_reserve_car.py
Last active February 21, 2018 06:57
urutu create test
#! /usr/bin/env python
import sys
import unittest
from lex_bot_tester.aws.alexa.alexaskilltest import AlexaSkillTest
verbose = True
class GeneratedTests(AlexaSkillTest):
def test_book_my_trip_reserve_car(self):