Adding edit and screenshot

This commit is contained in:
root
2024-03-13 12:27:08 +01:00
parent e6d087f148
commit b6ece56080
4 changed files with 97 additions and 7 deletions

20
functions/fscreen.py Normal file
View File

@@ -0,0 +1,20 @@
from config import *
import base64
def get_screenshot(vm_name):
dom = conn.lookupByName(vm_name)
stream = conn.newStream()
imageType = dom.screenshot(stream,0)
file = "tmp_screen_" + dom.name()
fileHandler = open(file, 'wb')
streamBytes = stream.recv(262120)
while streamBytes != b'':
fileHandler.write(streamBytes)
streamBytes = stream.recv(262120)
fileHandler.close()
print('Screenshot saved as type: ' + imageType)
stream.finish()
with open(file, "rb") as f:
data = base64.b64encode(f.read())
os.remove(file)
return data