psytricks 2.4.0a0__tar.gz → 2.4.0a1__tar.gz
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 psytricks might be problematic. Click here for more details.
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/PKG-INFO +1 -1
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/pyproject.toml +1 -1
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__init__.py +1 -1
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/psytricks-lib.ps1 +1 -1
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/restricks-server.ps1 +29 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/wrapper.py +36 -1
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/INSTALLATION.md +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/LICENSE +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/README.md +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/psytricks-wrapper.ps1 +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/restricks-server.example.xml +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/sampledata/GetAccessUsers.json +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/sampledata/GetMachineStatus.json +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/sampledata/GetSessions.json +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/cli.py +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/decoder.py +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/exceptions.py +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/literals.py +0 -0
- {psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/mappings.py +0 -0
|
@@ -105,6 +105,8 @@ if ($Shutdown) {
|
|
|
105
105
|
#region boilerplate
|
|
106
106
|
|
|
107
107
|
Add-PSSnapIn Citrix.Broker.Admin.V2 -ErrorAction Stop
|
|
108
|
+
# required for 'Get-ConfigSite' (see the "citrix-site" region below):
|
|
109
|
+
Add-PSSnapIn Citrix.Configuration.Admin.V2 -ErrorAction Stop
|
|
108
110
|
|
|
109
111
|
# locate and dot-source the libs file:
|
|
110
112
|
$LibPath = Join-Path $ScriptPath "psytricks-lib.ps1"
|
|
@@ -116,6 +118,30 @@ if (!(Test-Path $LibPath)) {
|
|
|
116
118
|
#endregion boilerplate
|
|
117
119
|
|
|
118
120
|
|
|
121
|
+
#region citrix-site
|
|
122
|
+
|
|
123
|
+
<#
|
|
124
|
+
The Citrix site the Delivery Controller belongs to is added to the "Status"
|
|
125
|
+
object of every JSON response, so clients can verify which site the data is
|
|
126
|
+
coming from (e.g. to notice they're talking to another site than expected).
|
|
127
|
+
|
|
128
|
+
The site is identified by its GUID, its name is for humans only (a new site may
|
|
129
|
+
well get the same name as the previous one). A controller can't change its site
|
|
130
|
+
while the server is running, so the site is only queried once - the server
|
|
131
|
+
refuses to start if it can't be determined (as 'ErrorActionPreference' is set to
|
|
132
|
+
"Stop").
|
|
133
|
+
#>
|
|
134
|
+
$CitrixSite = Get-ConfigSite -AdminAddress $AdminAddress
|
|
135
|
+
# a [guid] can't be serialized by 'ConvertTo-Json', so both are stored as strings:
|
|
136
|
+
$SiteGuid = [string]$CitrixSite.SiteGuid
|
|
137
|
+
$SiteName = [string]$CitrixSite.SiteName
|
|
138
|
+
if ($SiteGuid -eq "") {
|
|
139
|
+
throw "Unable to determine the Citrix site of [$AdminAddress]!"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#endregion citrix-site
|
|
143
|
+
|
|
144
|
+
|
|
119
145
|
#region route-keywords
|
|
120
146
|
|
|
121
147
|
$GetRoutes = @(
|
|
@@ -187,6 +213,8 @@ function Send-Response {
|
|
|
187
213
|
ScriptPath = $ScriptPath
|
|
188
214
|
PSyTricksVersion = $Version
|
|
189
215
|
Timestamp = [int64](Get-Date -UFormat %s)
|
|
216
|
+
SiteGuid = $SiteGuid
|
|
217
|
+
SiteName = $SiteName
|
|
190
218
|
}
|
|
191
219
|
|
|
192
220
|
$Payload = @{
|
|
@@ -478,6 +506,7 @@ function Start-ListenerLoop {
|
|
|
478
506
|
Write-Host "Starting: $ScriptPath" @Blue
|
|
479
507
|
Write-Host "PSyTricksVersion: $Version" @Blue
|
|
480
508
|
Write-Host "Citrix 'AdminAddress': $AdminAddress" @Blue
|
|
509
|
+
Write-Host "Citrix site: $SiteName ($SiteGuid)" @Blue
|
|
481
510
|
Write-Host "====================================================" @Blue
|
|
482
511
|
|
|
483
512
|
|
|
@@ -55,6 +55,15 @@ class ResTricksWrapper:
|
|
|
55
55
|
The server version as a list of version components, where the first
|
|
56
56
|
three components are of type `int` (representing `major.minor.patch`),
|
|
57
57
|
whereas the last component may be a `str` as well.
|
|
58
|
+
site_guid : str or None
|
|
59
|
+
The GUID of the Citrix site the server's Delivery Controller belongs
|
|
60
|
+
to, as given by the `Status` of the latest response (`None` before the
|
|
61
|
+
first response, or if the server doesn't provide it, e.g. a version
|
|
62
|
+
older than 2.4.0). Checking it right after a request tells which site
|
|
63
|
+
the data of that request's response is coming from.
|
|
64
|
+
site_name : str or None
|
|
65
|
+
The name of that Citrix site (same as for `site_guid`). For humans only,
|
|
66
|
+
as a new site may well get the same name as the previous one.
|
|
58
67
|
headers : dict
|
|
59
68
|
A dict of headers to be sent along the requests.
|
|
60
69
|
"""
|
|
@@ -63,6 +72,8 @@ class ResTricksWrapper:
|
|
|
63
72
|
self.base_url = "http://localhost:8080/" if not base_url else base_url
|
|
64
73
|
self.timeout = 5
|
|
65
74
|
self.server_version = [0, 0, 0, 0]
|
|
75
|
+
self.site_guid = None
|
|
76
|
+
self.site_name = None
|
|
66
77
|
|
|
67
78
|
# FIXME: currently "localhost" is hardcoded here as this is what the
|
|
68
79
|
# service expects (see `Listener.Prefixes` in `restricks-server.ps1` for
|
|
@@ -289,6 +300,25 @@ class ResTricksWrapper:
|
|
|
289
300
|
log.warning(response.text)
|
|
290
301
|
raise ValueError(f"Malformed response: {response.text}") from ex
|
|
291
302
|
|
|
303
|
+
def _record_site(self, data) -> None:
|
|
304
|
+
"""Record the Citrix site from the `Status` of a parsed response.
|
|
305
|
+
|
|
306
|
+
Both `site_guid` and `site_name` are set from every response, so they
|
|
307
|
+
always tell where the latest response is coming from - they're reset to
|
|
308
|
+
`None` if the response doesn't provide them (e.g. an older server).
|
|
309
|
+
|
|
310
|
+
Parameters
|
|
311
|
+
----------
|
|
312
|
+
data : list or dict or None
|
|
313
|
+
The parsed `JSON` of the response, see `send_get_request()`.
|
|
314
|
+
"""
|
|
315
|
+
status = {}
|
|
316
|
+
if isinstance(data, dict):
|
|
317
|
+
status = data.get("Status") or {}
|
|
318
|
+
self.site_guid = status.get("SiteGuid") or None
|
|
319
|
+
self.site_name = status.get("SiteName") or None
|
|
320
|
+
log.trace(f"Citrix site of the response: {self.site_name} ({self.site_guid})")
|
|
321
|
+
|
|
292
322
|
def _write_response_dump(self, response: requests.Response) -> Path | None:
|
|
293
323
|
"""Dump the response to disk if `dump_responses_to` is set."""
|
|
294
324
|
if not self.dump_responses_to:
|
|
@@ -364,6 +394,7 @@ class ResTricksWrapper:
|
|
|
364
394
|
raise json.JSONDecodeError(msg, doc=response.text, pos=0)
|
|
365
395
|
|
|
366
396
|
self._check_response(response)
|
|
397
|
+
self._record_site(data)
|
|
367
398
|
|
|
368
399
|
return data
|
|
369
400
|
|
|
@@ -430,9 +461,13 @@ class ResTricksWrapper:
|
|
|
430
461
|
|
|
431
462
|
if no_json:
|
|
432
463
|
log.debug(f"No-payload response status code: {response.status_code}")
|
|
464
|
+
# no `Status` to take the site from, so it's unknown for this one:
|
|
465
|
+
self._record_site(None)
|
|
433
466
|
return []
|
|
434
467
|
|
|
435
|
-
|
|
468
|
+
data = response.json(object_hook=parse_powershell_json)
|
|
469
|
+
self._record_site(data)
|
|
470
|
+
return data
|
|
436
471
|
|
|
437
472
|
def get_machine_status(self) -> list:
|
|
438
473
|
"""Send a `GET` request with `GetMachineStatus`.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/sampledata/GetAccessUsers.json
RENAMED
|
File without changes
|
{psytricks-2.4.0a0 → psytricks-2.4.0a1}/src/psytricks/__ps1__/sampledata/GetMachineStatus.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|