-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add uninstall script and other updates (#25)
* add alias for batterymanager for now * add uninstall script * test alias * add status messages * fix spacing before command * move command names and descriptions to their respective classes * make green * it's bytes not str * don't need * debug * test formatting * test formatting * does this fix it? * add temperature * add - * add - * fix * remove to fix * don't delete system .bashrc and don't delete community .bashrc for now * test uninstall * debug * add uninstall command to python CLI * fix * update README.md * fix battery * remove fork * last commit, remove from aliases * uninstall the entrypoint script Co-authored-by: AskAlice <[email protected]>
- Loading branch information
Showing
13 changed files
with
144 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from emu_commands.fork import Fork | ||
from emu_commands.update import Update | ||
from emu_commands.panda import Panda | ||
from emu_commands.debug import Debug | ||
from emu_commands.info import Info | ||
from emu_commands.uninstall import Uninstall | ||
|
||
|
||
EMU_COMMANDS = [Fork(), Update(), Panda(), Debug(), Info(), Uninstall()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from emu_commands.base import CommandBase, Command, Flag | ||
from py_utils.emu_utils import run, warning, error, check_output, COLORS, success | ||
|
||
class Info(CommandBase): | ||
def __init__(self): | ||
super().__init__() | ||
self.name = 'info' | ||
self.description = '📈 Statistics about your device' | ||
|
||
self.commands = {'battery': Command(description='🔋 see information about the state of your battery')} | ||
|
||
def _battery(self): | ||
r = check_output('dumpsys batterymanager') | ||
if not r: | ||
error('Unable to get battery status!') | ||
return | ||
r = r.decode('utf-8').split('\n') | ||
r = [i.strip() for i in r if i != ''][1:] | ||
battery_idxs = {'level': 7, 'temperature': 10} | ||
success('Battery info:') | ||
for name in battery_idxs: | ||
idx = battery_idxs[name] | ||
info = r[idx] | ||
|
||
value = float(info.split(': ')[1]) | ||
if name == 'temperature': | ||
value /= 10 | ||
value = str(value) + ' °C' | ||
else: | ||
value = str(value) + '%' | ||
|
||
value = COLORS.SUCCESS + str(value) | ||
name = COLORS.WARNING + name.title() | ||
print('- {}: {}{}'.format(name, value, COLORS.ENDC)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from emu_commands.base import CommandBase, Command, Flag | ||
from py_utils.emu_utils import run, warning, error, check_output, COLORS, success, input_with_options, UNINSTALL_PATH | ||
|
||
class Uninstall(CommandBase): | ||
def __init__(self): | ||
super().__init__() | ||
self.name = 'uninstall' | ||
self.description = '👋 Uninstalls emu' | ||
|
||
def _uninstall(self): | ||
print('Are you sure you want to uninstall emu?') | ||
if input_with_options(['Y', 'n'], 'n')[0] == 0: | ||
run(['sh', UNINSTALL_PATH]) | ||
else: | ||
error('Not uninstalling!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/bash | ||
|
||
# COMMUNITY_PATH=/data/community # probably shouldn't remove since it will hold forks in the future | ||
COMMUNITY_BASHRC_PATH=/data/community/.bashrc | ||
OH_MY_COMMA_PATH=/data/community/.oh-my-comma | ||
|
||
#echo "Deleting $COMMUNITY_BASHRC_PATH" | ||
#rm $COMMUNITY_BASHRC_PATH | ||
sed -i.bak.$(date +"%Y-%m-%d-%T") -e '/^## BEGIN \.oh-my-comma magic ###/,/^### End of \.oh-my-comma magic ###/d' ${COMMUNITY_BASHRC_PATH} | ||
echo "Deleting $OH_MY_COMMA_PATH" | ||
rm -rf $OH_MY_COMMA_PATH | ||
|
||
echo "Uninstalled!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters