ver Jan15th
merged zdy into main
This commit is contained in:
@@ -205,15 +205,15 @@ class SetupController:
|
|||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logger.error("An error occurred while trying to send the request: %s", e)
|
logger.error("An error occurred while trying to send the request: %s", e)
|
||||||
|
|
||||||
def _launch_setup(self, command: Union[str, List[str]]):
|
def _launch_setup(self, command: Union[str, List[str]], shell: bool = False):
|
||||||
if not command:
|
if not command:
|
||||||
raise Exception("Empty command to launch.")
|
raise Exception("Empty command to launch.")
|
||||||
|
|
||||||
if isinstance(command, str) and len(command.split()) > 1:
|
if not shell and isinstance(command, str) and len(command.split()) > 1:
|
||||||
logger.warning("Command should be a list of strings. Now it is a string. Will split it by space.")
|
logger.warning("Command should be a list of strings. Now it is a string. Will split it by space.")
|
||||||
command = command.split()
|
command = command.split()
|
||||||
|
|
||||||
payload = json.dumps({"command": command})
|
payload = json.dumps({"command": command, "shell": shell})
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -245,7 +245,7 @@ class SetupController:
|
|||||||
|
|
||||||
while not terminates:
|
while not terminates:
|
||||||
try:
|
try:
|
||||||
response = requests.post(self.http_server_setup_root + "/execute", headers=headers, data=payload)
|
response = requests.post(self.http_server + "/setup" + "/execute", headers=headers, data=payload)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
results: Dict[str, str] = response.json()
|
results: Dict[str, str] = response.json()
|
||||||
if stdout:
|
if stdout:
|
||||||
|
|||||||
@@ -58,11 +58,12 @@ def execute_command():
|
|||||||
@app.route('/setup/launch', methods=["POST"])
|
@app.route('/setup/launch', methods=["POST"])
|
||||||
def launch_app():
|
def launch_app():
|
||||||
data = request.json
|
data = request.json
|
||||||
command: List[str] = data.get("command", [])
|
shell = data.get("shell", False)
|
||||||
|
command: List[str] = data.get("command", "" if shell else [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(command)
|
subprocess.Popen(command, shell=shell)
|
||||||
return "{:} launched successfully".format(" ".join(command))
|
return "{:} launched successfully".format(command if shell else " ".join(command))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"status": "error", "message": str(e)}), 500
|
return jsonify({"status": "error", "message": str(e)}), 500
|
||||||
|
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ git+https://github.com/moses-palmer/pynput.git@refs/pull/541/head # to make sure
|
|||||||
requests
|
requests
|
||||||
flask
|
flask
|
||||||
numpy
|
numpy
|
||||||
|
lxml
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "06fe7178-4491-4589-810f-2e2bc9502122",
|
"id": "06fe7178-4491-4589-810f-2e2bc9502122",
|
||||||
"snapshot": "thunderbird",
|
"snapshot": "thunderbird",
|
||||||
"instruction": "Could you help me back up all the email files in my profile to ~/email.bak? Please save them separately in eml format.",
|
"instruction": "Could you help me back up all the email files in my profile to ~/emails.bak? Please save them separately in eml format.",
|
||||||
"source": "https://www.quora.com/How-do-I-backup-email-files-in-Mozilla-Thunderbird",
|
"source": "https://www.quora.com/How-do-I-backup-email-files-in-Mozilla-Thunderbird",
|
||||||
"config": [
|
"config": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
{
|
||||||
|
"id": "d088f539-cab4-4f9a-ac92-9999fc3a656e",
|
||||||
|
"snapshot": "thunderbird",
|
||||||
|
"instruction": "Attach the my AWS bill to the email. The bill is stored at ~/aws-bill.pdf. Don't close it or send it. I haven't finish all the contents.",
|
||||||
|
"source": "https://support.mozilla.org/en-US/kb/how-use-attachments",
|
||||||
|
"config": [
|
||||||
|
{
|
||||||
|
"type": "download",
|
||||||
|
"parameters": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1JDUxe8Cs0D9La9ECoYbHJAIQ95DZfkDT&export=download&authuser=0&confirm=t&uuid=1e0f94d8-4fb1-4f9b-878a-516cf4a7ebc4&at=APZUnTXHBZKTuW_vQUzi-1XKuAYg:1705242554801",
|
||||||
|
"path": "/home/user/aws-bill.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1EHLRWzBCOsyERkSMUnTF2pnsR0n6ZvtR&export=download&authuser=0&confirm=t&uuid=de09bd5e-bef8-499a-b599-c642af190e10&at=APZUnTXqOsQkxl0zMSX6R1Sgp_v3:1704362491712",
|
||||||
|
"path": "/home/user/thunderbird-profile.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=17LutYTkEXhM__sxvrdldar7p-eQba4Pm&export=download&authuser=0&confirm=t&uuid=34730e1c-0fac-401a-ab91-102a47f02224&at=APZUnTX4eFTnG9vnYlQEJX6N0jqP:1705227498314",
|
||||||
|
"path": "/home/user/.aws-bill-mail-body.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "execute",
|
||||||
|
"parameters": {
|
||||||
|
"command": [
|
||||||
|
"tar",
|
||||||
|
"-xzv",
|
||||||
|
"--recursive-unlink",
|
||||||
|
"-f",
|
||||||
|
"/home/user/thunderbird-profile.tar.gz",
|
||||||
|
"-C",
|
||||||
|
"/home/user/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "launch",
|
||||||
|
"parameters": {
|
||||||
|
"command": "/usr/bin/thunderbird -compose \"from='Anonym Tester <anonym-x2024@outlook.com>',to=assistant@outlook.com,subject='New-month AWS Bill',body='$(cat /home/user/.aws-bill-mail-body.html)'\"",
|
||||||
|
"shell": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trajectory": "trajectories/d088f539-cab4-4f9a-ac92-9999fc3a656e",
|
||||||
|
"related_apps": [
|
||||||
|
"thunderbird"
|
||||||
|
],
|
||||||
|
"evaluator": {
|
||||||
|
"postconfig": [
|
||||||
|
{
|
||||||
|
"type": "download",
|
||||||
|
"parameters": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1abb7PPPRGGy3elpq2vTXe2aKTMOrbm7c&export=download&authuser=0&confirm=t&uuid=652a3d4c-278e-499c-bb26-58d0f70aa317&at=APZUnTXs_ZTZzOF3QrBa_rMjMr08:1705287009269",
|
||||||
|
"path": "/home/user/show-thunderbird-attachments.py"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "execute",
|
||||||
|
"parameters": {
|
||||||
|
"command": ["pip", "install", "cssselect"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "execute",
|
||||||
|
"parameters": {
|
||||||
|
"command": [
|
||||||
|
"python",
|
||||||
|
"/home/user/show-thunderbird-attachments.py",
|
||||||
|
"New-month AWS Bill",
|
||||||
|
"aws-bill.pdf"
|
||||||
|
],
|
||||||
|
"stdout": "check-attachments.output"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"func": "check_list",
|
||||||
|
"result": {
|
||||||
|
"type": "cache_file",
|
||||||
|
"path": "check-attachments.output"
|
||||||
|
},
|
||||||
|
"expected": {
|
||||||
|
"type": "rule",
|
||||||
|
"rules": {
|
||||||
|
"expect": [
|
||||||
|
"Attachment added!"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"id": "d088f539-cab4-4f9a-ac92-9999fc3a656e",
|
||||||
|
"snapshot": "thunderbird",
|
||||||
|
"instruction": "Attach the my AWS bill to the email. The bill is stored at ~/aws-bill.pdf. Don't close it or send it. I haven't finish all the contents.",
|
||||||
|
"source": "https://support.mozilla.org/en-US/kb/how-use-attachments",
|
||||||
|
"config": [
|
||||||
|
{
|
||||||
|
"type": "download",
|
||||||
|
"parameters": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1JDUxe8Cs0D9La9ECoYbHJAIQ95DZfkDT&export=download&authuser=0&confirm=t&uuid=1e0f94d8-4fb1-4f9b-878a-516cf4a7ebc4&at=APZUnTXHBZKTuW_vQUzi-1XKuAYg:1705242554801",
|
||||||
|
"path": "/home/user/aws-bill.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1EHLRWzBCOsyERkSMUnTF2pnsR0n6ZvtR&export=download&authuser=0&confirm=t&uuid=de09bd5e-bef8-499a-b599-c642af190e10&at=APZUnTXqOsQkxl0zMSX6R1Sgp_v3:1704362491712",
|
||||||
|
"path": "/home/user/thunderbird-profile.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=17LutYTkEXhM__sxvrdldar7p-eQba4Pm&export=download&authuser=0&confirm=t&uuid=34730e1c-0fac-401a-ab91-102a47f02224&at=APZUnTX4eFTnG9vnYlQEJX6N0jqP:1705227498314",
|
||||||
|
"path": "/home/user/.aws-bill-mail-body.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trajectory": "trajectories/d088f539-cab4-4f9a-ac92-9999fc3a656e",
|
||||||
|
"related_apps": [
|
||||||
|
"thunderbird"
|
||||||
|
],
|
||||||
|
"evaluator": {
|
||||||
|
"postconfig": [
|
||||||
|
{
|
||||||
|
"type": "download",
|
||||||
|
"parameters": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1abb7PPPRGGy3elpq2vTXe2aKTMOrbm7c&export=download&authuser=0&confirm=t&uuid=652a3d4c-278e-499c-bb26-58d0f70aa317&at=APZUnTXs_ZTZzOF3QrBa_rMjMr08:1705287009269",
|
||||||
|
"path": "/home/user/show-thunderbird-attachments.py"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "execute",
|
||||||
|
"parameters": {
|
||||||
|
"command": ["pip", "install", "cssselect"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "execute",
|
||||||
|
"parameters": {
|
||||||
|
"command": [
|
||||||
|
"python",
|
||||||
|
"/home/user/show-thunderbird-attachments.py",
|
||||||
|
"New-month AWS Bill",
|
||||||
|
"aws-bill.pdf"
|
||||||
|
],
|
||||||
|
"stdout": "check-attachments.output"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"func": "check_list",
|
||||||
|
"result": {
|
||||||
|
"type": "cache_file",
|
||||||
|
"path": "check-attachments.output"
|
||||||
|
},
|
||||||
|
"expected": {
|
||||||
|
"type": "rule",
|
||||||
|
"rules": {
|
||||||
|
"expect": [
|
||||||
|
"Attachment added!"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user