5
$\begingroup$

If I'm given a paclet server, "http://paclet.serv.er/" how can I determine what paclets are on it to install?

E.g. how could I find all of the ServiceConnections on this server: "http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer"?

$\endgroup$
  • $\begingroup$ In version 12.1, the functionPacletFindRemote does this to some extent. $\endgroup$ – Carl Lange Mar 22 at 15:36
6
$\begingroup$

The paclet data resides in a compressed file called PacletSite.mz". So we can import all of the paclets like so:

getPacletSiteData[server_] :=
  Block[
   {
    $Context = "PacletManager`Private`",
    $ContextPath = $ContextPath
    },
   ReplaceAll[
    Import[
     URLBuild@{server, "PacletSite.mz"},
     {"ZIP", "PacletSite.m"}
     ],
    (s_Symbol -> v_) :>
     (SymbolName[s] -> v)
    ]
   ];

Then to get the service connection we'll just implement a little name-based selector:

selectByName[PacletSite[p__], pat_] :=
 Pick[
  {p},
  StringMatchQ[pat]@
   Lookup[
    List @@@ {p},
    "Name"
    ]
  ]

And then running that we get the following:

paclets = 
  getPacletSiteData[
   "http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer"];

conns =
 selectByName[paclets, "ServiceConnection_*"] // 
  DeleteDuplicatesBy[#["Name"] &]

{
   Paclet["ServiceConnection_DeckOfCards","1.0.2",<>],
   Paclet["ServiceConnection_NASA","1.0.1",<>],
   Paclet["ServiceConnection_StackExchange","1.1.6",<>],
   Paclet["ServiceConnection_WolframCommunity","1.0.3",<>],
   Paclet["ServiceConnection_GitHub","1.0.3",<>],
   Paclet["ServiceConnection_GoogleDrive","1.0.2",<>],
   Paclet["ServiceConnection_Qwant","1.0.5",<>],
   Paclet["ServiceConnection_Git","1.0.0",<>],
   Paclet["ServiceConnection_GitHubJobs","1.0.0",<>]
   } 

You could then install any of these like so:

pac = RandomChoice[conns]["Name"]

"ServiceConnection_GitHubJobs"

PacletInstall[pac,
 "Site" ->
  "http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer"
 ]

rara

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.