@scrypted/server 0.0.161 → 0.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @scrypted/server might be problematic. Click here for more details.
- package/package.json +2 -2
- package/python/plugin-remote.py +67 -23
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrypted/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.162",
|
|
4
4
|
"description": "",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@mapbox/node-pre-gyp": "^1.0.8",
|
|
7
7
|
"@scrypted/ffmpeg": "^1.0.10",
|
|
8
|
-
"@scrypted/types": "^0.0.
|
|
8
|
+
"@scrypted/types": "^0.0.25",
|
|
9
9
|
"adm-zip": "^0.5.3",
|
|
10
10
|
"axios": "^0.21.1",
|
|
11
11
|
"body-parser": "^1.19.0",
|
package/python/plugin-remote.py
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from typing import Any
|
|
5
|
-
import subprocess
|
|
6
|
-
import zipfile
|
|
7
|
-
import time
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
8
4
|
import base64
|
|
9
|
-
|
|
10
|
-
from typing import Tuple
|
|
11
|
-
import aiofiles
|
|
5
|
+
import gc
|
|
12
6
|
import json
|
|
13
|
-
from asyncio.events import AbstractEventLoop
|
|
14
|
-
import asyncio
|
|
15
|
-
import rpc
|
|
16
|
-
from collections.abc import Mapping
|
|
17
|
-
from scrypted_python.scrypted_sdk.types import DeviceManifest, MediaManager, ScryptedInterfaceProperty
|
|
18
|
-
import scrypted_python.scrypted_sdk.types
|
|
19
|
-
from asyncio.futures import Future
|
|
20
|
-
from asyncio.streams import StreamReader, StreamWriter
|
|
21
7
|
import os
|
|
22
|
-
from os import sys
|
|
23
8
|
import platform
|
|
9
|
+
import resource
|
|
24
10
|
import shutil
|
|
25
|
-
import
|
|
11
|
+
import subprocess
|
|
26
12
|
import threading
|
|
13
|
+
import time
|
|
14
|
+
import zipfile
|
|
15
|
+
from asyncio.events import AbstractEventLoop
|
|
16
|
+
from asyncio.futures import Future
|
|
17
|
+
from asyncio.streams import StreamReader, StreamWriter
|
|
18
|
+
from collections.abc import Mapping
|
|
19
|
+
from io import StringIO
|
|
20
|
+
from os import sys
|
|
21
|
+
from typing import Any, Optional, Set, Tuple
|
|
22
|
+
|
|
23
|
+
import aiofiles
|
|
27
24
|
import gi
|
|
28
|
-
import
|
|
25
|
+
import scrypted_python.scrypted_sdk.types
|
|
26
|
+
from scrypted_python.scrypted_sdk.types import (Device, DeviceManifest,
|
|
27
|
+
MediaManager,
|
|
28
|
+
ScryptedInterfaceProperty,
|
|
29
|
+
Storage)
|
|
30
|
+
from typing_extensions import TypedDict
|
|
31
|
+
|
|
32
|
+
import rpc
|
|
33
|
+
|
|
29
34
|
gi.require_version('Gst', '1.0')
|
|
30
35
|
|
|
31
|
-
from gi.repository import
|
|
36
|
+
from gi.repository import GLib, Gst
|
|
32
37
|
|
|
33
38
|
Gst.init(None)
|
|
34
39
|
|
|
@@ -82,11 +87,33 @@ class DeviceState(scrypted_python.scrypted_sdk.types.DeviceState):
|
|
|
82
87
|
self.systemManager.api.setState(self.nativeId, property, value)
|
|
83
88
|
|
|
84
89
|
|
|
85
|
-
class DeviceStorage:
|
|
90
|
+
class DeviceStorage(Storage):
|
|
86
91
|
id: str
|
|
87
92
|
nativeId: str
|
|
88
|
-
storage: Mapping[str, str]
|
|
93
|
+
storage: Mapping[str, str]
|
|
94
|
+
remote: PluginRemote
|
|
95
|
+
loop: AbstractEventLoop
|
|
96
|
+
|
|
97
|
+
def update_storage(self):
|
|
98
|
+
self.remote.api.setStorage(self.nativeId, self.storage)
|
|
99
|
+
|
|
100
|
+
def getItem(self, key: str) -> str:
|
|
101
|
+
return self.storage.get(key, None)
|
|
102
|
+
|
|
103
|
+
def setItem(self, key: str, value: str):
|
|
104
|
+
self.storage[key] = value
|
|
105
|
+
self.update_storage()
|
|
106
|
+
|
|
107
|
+
def removeItem(self, key: str):
|
|
108
|
+
self.storage.pop(key, None)
|
|
109
|
+
self.update_storage()
|
|
89
110
|
|
|
111
|
+
def getKeys(self) -> Set[str]:
|
|
112
|
+
return self.storage.keys()
|
|
113
|
+
|
|
114
|
+
def clear(self):
|
|
115
|
+
self.storage = {}
|
|
116
|
+
self.update_storage()
|
|
90
117
|
|
|
91
118
|
class DeviceManager(scrypted_python.scrypted_sdk.types.DeviceManager):
|
|
92
119
|
def __init__(self, nativeIds: Mapping[str, DeviceStorage], systemManager: SystemManager) -> None:
|
|
@@ -104,6 +131,20 @@ class DeviceManager(scrypted_python.scrypted_sdk.types.DeviceManager):
|
|
|
104
131
|
async def onDevicesChanged(self, devices: DeviceManifest) -> None:
|
|
105
132
|
return await self.systemManager.api.onDevicesChanged(devices)
|
|
106
133
|
|
|
134
|
+
async def onDeviceDiscovered(self, devices: Device) -> str:
|
|
135
|
+
return await self.systemManager.api.onDeviceDiscovered(devices)
|
|
136
|
+
|
|
137
|
+
async def onDeviceRemoved(self, nativeId: str) -> None:
|
|
138
|
+
return await self.systemManager.api.onDeviceRemoved(nativeId)
|
|
139
|
+
|
|
140
|
+
async def onMixinEvent(self, id: str, mixinDevice: Any, eventInterface: str, eventData: Any) -> None:
|
|
141
|
+
return await self.systemManager.api.onMixinEvent(id, mixinDevice, eventInterface, eventData)
|
|
142
|
+
|
|
143
|
+
async def requestRestart(self) -> None:
|
|
144
|
+
return await self.systemManager.api.onMixinEvent(id)
|
|
145
|
+
|
|
146
|
+
def getDeviceStorage(self, nativeId: str = None) -> Storage:
|
|
147
|
+
return self.nativeIds.get(nativeId, None)
|
|
107
148
|
|
|
108
149
|
class BufferSerializer(rpc.RpcSerializer):
|
|
109
150
|
def serialize(self, value):
|
|
@@ -253,7 +294,10 @@ class PluginRemote:
|
|
|
253
294
|
if id:
|
|
254
295
|
ds = DeviceStorage()
|
|
255
296
|
ds.id = id
|
|
297
|
+
ds.nativeId = nativeId
|
|
256
298
|
ds.storage = storage
|
|
299
|
+
ds.remote = self
|
|
300
|
+
ds.loop = self.loop
|
|
257
301
|
self.nativeIds[nativeId] = ds
|
|
258
302
|
else:
|
|
259
303
|
self.nativeIds.pop(nativeId, None)
|