Skip to content

Commit 0266543

Browse files
committed
no wr services patch
1 parent 842f1cb commit 0266543

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

Common/Patches/NoWR.wl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BeginPackage["CoffeeLiqueur`Patches`NoWR`"]
2+
3+
Begin["`Private`"]
4+
5+
With[{
6+
words = DeleteDuplicates @
7+
Select[StringLength[#] > 2 &] @ Flatten @
8+
Map[
9+
StringCases[#,
10+
CharacterRange["A", "Z"] ~~
11+
Except[CharacterRange["A", "Z"]] ..] &] @
12+
Select[StringLength[#] > 2 &] @
13+
Names["System`*"]
14+
},
15+
Unprotect[RandomWord];
16+
ClearAll[RandomWord];
17+
18+
RandomWord[] := RandomChoice @ words;
19+
RandomWord[n_Integer] := RandomChoice[words, n];
20+
]
21+
22+
End[]
23+
24+
EndPackage[]

Kernel/LocalKernel.wl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ start[k_LocalKernelObject] := Module[{link},
288288
LinkWrite[link, Unevaluated[ PacletDirectoryLoad[Directory[] ] ] ];
289289
LinkWrite[link, Unevaluated[ PacletDirectoryLoad[FileNameJoin[{Directory[], "wl_packages"}] ] ] ];
290290

291+
If[TrueQ @ Internal`$NoWRServices,
292+
LinkWrite[link, Unevaluated[ Get[FileNameJoin[{Directory[], "Common", "Patches", "NoWR.wl"}] ] ] ];
293+
];
294+
291295
LinkWrite[link, EnterTextPacket["<<KirillBelov`CSockets`"] ];
292296
LinkWrite[link, EnterTextPacket["<<KirillBelov`Objects`"] ];
293297
LinkWrite[link, EnterTextPacket["<<KirillBelov`Internal`"] ];

Scripts/start.wls

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,14 @@ WLJSPackages`Load[ AppExtensions`ExtensionsDir ];
198198

199199
{loadSettings, storeSettings} = Get[FileNameJoin[{"Frontend", "Settings.wl"}] ];
200200

201-
RandomWord[];
202-
201+
(* check if there is internet or connection to WR servers *)
202+
(* NetworkConnected is not robust enough *)
203+
Internal`$NoWRServices = !StringQ[RandomWord[]];
203204

205+
If[TrueQ @ Internal`$NoWRServices,
206+
Echo["No WR servers are reachable, we will apply patches to some system symbols..."];
207+
Get[FileNameJoin[{Directory[], "Common", "Patches", "NoWR.wl"}]]
208+
];
204209

205210
WLJSPackages`Includes["js"];
206211
WLJSPackages`Includes["frontend"];

0 commit comments

Comments
 (0)