@scrypted/server 0.7.58 → 0.7.60
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 +1 -1
- package/python/plugin_remote.py +5 -3
- package/src/media-helpers.ts +7 -0
- package/src/plugin/media.ts +1 -20
- package/src/plugin/mediaobject.ts +22 -0
- package/src/plugin/system.ts +2 -2
package/package.json
CHANGED
package/python/plugin_remote.py
CHANGED
@@ -224,6 +224,7 @@ class PluginRemote:
|
|
224
224
|
mediaManager: MediaManager
|
225
225
|
loop: AbstractEventLoop
|
226
226
|
consoles: Mapping[str, Future[Tuple[StreamReader, StreamWriter]]] = {}
|
227
|
+
ptimeSum = 0
|
227
228
|
|
228
229
|
def __init__(self, peer: rpc.RpcPeer, api, pluginId, hostInfo, loop: AbstractEventLoop):
|
229
230
|
self.allMemoryStats = {}
|
@@ -309,7 +310,7 @@ class PluginRemote:
|
|
309
310
|
clusterPeers: Mapping[int, asyncio.Future[rpc.RpcPeer]] = {}
|
310
311
|
async def connectRPCObject(value):
|
311
312
|
clusterObject = getattr(value, '__cluster')
|
312
|
-
if not
|
313
|
+
if type(clusterObject) is not dict:
|
313
314
|
return value
|
314
315
|
|
315
316
|
if clusterObject.get('id', None) != clusterId:
|
@@ -522,6 +523,7 @@ class PluginRemote:
|
|
522
523
|
forkPeer.peerName = 'thread'
|
523
524
|
|
524
525
|
async def updateStats(stats):
|
526
|
+
self.ptimeSum += stats['cpu']['user']
|
525
527
|
self.allMemoryStats[forkPeer] = stats
|
526
528
|
forkPeer.params['updateStats'] = updateStats
|
527
529
|
|
@@ -535,6 +537,7 @@ class PluginRemote:
|
|
535
537
|
self.allMemoryStats.pop(forkPeer)
|
536
538
|
parent_conn.close()
|
537
539
|
rpcTransport.executor.shutdown()
|
540
|
+
pluginFork.worker.kill()
|
538
541
|
asyncio.run_coroutine_threadsafe(forkReadLoop(), loop=self.loop)
|
539
542
|
getRemote = await forkPeer.getParam('getRemote')
|
540
543
|
remote: PluginRemote = await getRemote(self.api, self.pluginId, self.hostInfo)
|
@@ -614,7 +617,7 @@ class PluginRemote:
|
|
614
617
|
pass
|
615
618
|
|
616
619
|
async def start_stats_runner(self):
|
617
|
-
update_stats = await self.peer.getParam('updateStats')
|
620
|
+
update_stats = await self.peer.getParam('updateStats') + self.ptimeSum
|
618
621
|
if not update_stats:
|
619
622
|
print('host did not provide update_stats')
|
620
623
|
return
|
@@ -634,7 +637,6 @@ class PluginRemote:
|
|
634
637
|
heapTotal = 0
|
635
638
|
|
636
639
|
for _, stats in self.allMemoryStats.items():
|
637
|
-
ptime += stats['cpu']['user']
|
638
640
|
heapTotal += stats['memoryUsage']['heapTotal']
|
639
641
|
|
640
642
|
stats = {
|
package/src/media-helpers.ts
CHANGED
package/src/plugin/media.ts
CHANGED
@@ -9,27 +9,8 @@ import Graph from 'node-dijkstra';
|
|
9
9
|
import os from 'os';
|
10
10
|
import path from 'path';
|
11
11
|
import MimeType from 'whatwg-mimetype';
|
12
|
-
import { RpcPeer } from "../rpc";
|
13
12
|
import { MediaObjectRemote } from "./plugin-api";
|
14
|
-
|
15
|
-
class MediaObject implements MediaObjectRemote {
|
16
|
-
__proxy_props: any;
|
17
|
-
|
18
|
-
constructor(public mimeType: string, public data: any, options: MediaObjectOptions) {
|
19
|
-
this.__proxy_props = {}
|
20
|
-
options ||= {};
|
21
|
-
options.mimeType = mimeType;
|
22
|
-
for (const [key, value] of Object.entries(options)) {
|
23
|
-
if (RpcPeer.isTransportSafe(value))
|
24
|
-
this.__proxy_props[key] = value;
|
25
|
-
(this as any)[key] = value;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
async getData(): Promise<Buffer | string> {
|
30
|
-
return Promise.resolve(this.data);
|
31
|
-
}
|
32
|
-
}
|
13
|
+
import { MediaObject } from "./mediaobject";
|
33
14
|
|
34
15
|
function typeMatches(target: string, candidate: string): boolean {
|
35
16
|
// candidate will accept anything
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { MediaObjectOptions } from "@scrypted/types";
|
2
|
+
import { RpcPeer } from "../rpc";
|
3
|
+
import { MediaObjectRemote } from "./plugin-api";
|
4
|
+
|
5
|
+
export class MediaObject implements MediaObjectRemote {
|
6
|
+
__proxy_props: any;
|
7
|
+
|
8
|
+
constructor(public mimeType: string, public data: any, options: MediaObjectOptions) {
|
9
|
+
this.__proxy_props = {}
|
10
|
+
options ||= {};
|
11
|
+
options.mimeType = mimeType;
|
12
|
+
for (const [key, value] of Object.entries(options)) {
|
13
|
+
if (RpcPeer.isTransportSafe(value))
|
14
|
+
this.__proxy_props[key] = value;
|
15
|
+
(this as any)[key] = value;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
async getData(): Promise<Buffer | string> {
|
20
|
+
return Promise.resolve(this.data);
|
21
|
+
}
|
22
|
+
}
|
package/src/plugin/system.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { EventListener, EventListenerOptions, EventListenerRegister, Logger, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedInterfaceDescriptor, ScryptedInterfaceDescriptors, ScryptedInterfaceProperty, SystemDeviceState, SystemManager } from "@scrypted/types";
|
2
2
|
import { EventRegistry } from "../event-registry";
|
3
3
|
import { PrimitiveProxyHandler, RpcPeer } from '../rpc';
|
4
|
-
import type { PluginComponent } from "../services/plugin";
|
4
|
+
// import type { PluginComponent } from "../services/plugin";
|
5
5
|
import { getInterfaceMethods, getInterfaceProperties, getPropertyInterfaces, isValidInterfaceMethod, propertyInterfaces } from "./descriptor";
|
6
6
|
import { PluginAPI } from "./plugin-api";
|
7
7
|
|
@@ -122,7 +122,7 @@ class DeviceProxyHandler implements PrimitiveProxyHandler<any>, ScryptedDevice {
|
|
122
122
|
}
|
123
123
|
|
124
124
|
async setMixins(mixins: string[]) {
|
125
|
-
const plugins = await this.systemManager.getComponent('plugins') as PluginComponent;
|
125
|
+
const plugins = await this.systemManager.getComponent('plugins');// as PluginComponent;
|
126
126
|
await plugins.setMixins(this.id, mixins);
|
127
127
|
}
|
128
128
|
|