-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCommandsExecution.py
61 lines (50 loc) · 1.52 KB
/
CommandsExecution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""$
{
"name": "CommandsExecution",
"displayName": "",
"description": "CommandsExecution",
"inputPattern": {
"type": "object",
"required": [],
"properties": {}
},
"outputPattern": {
"type": "object",
"required": [],
"properties": {}
},
"tag": "Example",
"testCases": [
{}
],
"aiPrompt": "",
"greeting": ""
}
$"""
import json
def mindsflow_function(event, context) -> dict:
"""
This is the main function that processes an event within a given context.
Args:
event (class Event): Containing mindsflow internal api and request information.
case1: event.get("param") # inference parameters
case2: event.chat.messages(data) # call mindsflow api
context (class Context): Containing execution context and additional environment information.
Returns:
dict: A result dictionary meeting the Output Pattern.
"""
import zipfile
import subprocess
'''def unzip_folder(path_to_zip_file, directory_to_extract_to):
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
zip_ref.extractall(directory_to_extract_to)'''
# usage
#unzip_folder("fonts.zip", "fonts")
def execute_command(command):
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
execute_command("pip uninstall spleeter")
result = {
'data': 'Hello, MindsFlow User!'
}
return result