synapse.tools package

Submodules

synapse.tools.autodoc module

class synapse.tools.autodoc.DocHelp(ctors, types, forms, props, univs)[source]

Bases: object

Helper to pre-compute all doc strings hierarchically

synapse.tools.autodoc.docConfdefs(ctor, reflink=':ref:`devops-cell-config`')[source]
synapse.tools.autodoc.docModel(outp, core)[source]
synapse.tools.autodoc.docStormTypes()[source]
synapse.tools.autodoc.docStormpkg(pkgpath)[source]
synapse.tools.autodoc.docStormsvc(ctor)[source]
synapse.tools.autodoc.main(argv, outp=None)[source]
synapse.tools.autodoc.makeargparser()[source]
synapse.tools.autodoc.processCtors(rst, dochelp, ctors)[source]
Parameters:
Returns:

None

synapse.tools.autodoc.processFormsProps(rst, dochelp, forms, univ_names)[source]
synapse.tools.autodoc.processStormCmds(rst, pkgname, commands)[source]
Parameters:
  • rst (RstHelp) –
  • pkgname (str) –
  • commands (list) –
Returns:

None

synapse.tools.autodoc.processTypes(rst, dochelp, types)[source]
Parameters:
Returns:

None

synapse.tools.autodoc.processUnivs(rst, dochelp, univs)[source]

synapse.tools.backup module

synapse.tools.backup.backup(srcdir, dstdir, skipdirs=None)[source]

Create a backup of a Synapse application.

Parameters:
  • srcdir (str) – Path to the directory to backup.
  • dstdir (str) – Path to backup target directory.
  • skipdirs (list or None) – Optional list of relative directory name glob patterns to exclude from the backup.

Note

Running this method from the same process as a running user of the directory may lead to a segmentation fault

synapse.tools.backup.backup_lmdb(env, dstdir, txn=None)[source]
synapse.tools.backup.capturelmdbs(srcdir, skipdirs=None, onlydirs=None)[source]

A context manager that opens all the lmdb files under a srcdir and makes a read transaction. All transactions are aborted and environments closed when the context is exited.

Yields:Dict[str, Tuple[lmdb.Environment, lmdb.Transaction]] – Maps path to environment, transaction
synapse.tools.backup.main(argv)[source]
synapse.tools.backup.parse_args(argv)[source]
synapse.tools.backup.txnbackup(lmdbinfo, srcdir, dstdir, skipdirs=None)[source]

Create a backup of a Synapse application under a (hopefully consistent) set of transactions.

Parameters:
  • lmdbinfo (Dict[str, Tuple[lmdb.Environment, lmdb.Transaction]]) – Maps of path to environment, transaction
  • srcdir (str) – Path to the directory to backup.
  • dstdir (str) – Path to backup target directory.
  • skipdirs (list or None) – Optional list of relative directory name glob patterns to exclude from the backup.

Note

Running this method from the same process as a running user of the directory may lead to a segmentation fault

synapse.tools.cellauth module

synapse.tools.cellauth.handleList(opts)[source]
synapse.tools.cellauth.handleModify(opts)[source]
synapse.tools.cellauth.main(argv, outprint=None)[source]
synapse.tools.cellauth.makeargparser()[source]
synapse.tools.cellauth.printuser(user, details=False, cell=None)[source]
synapse.tools.cellauth.reprrule(rule)[source]

synapse.tools.cmdr module

synapse.tools.cmdr.main(argv)[source]
synapse.tools.cmdr.runcmdr(argv, item)[source]

synapse.tools.csvtool module

synapse.tools.csvtool.main(argv, outp=<synapse.lib.output.OutPut object>)[source]
synapse.tools.csvtool.makeargparser()[source]

synapse.tools.easycert module

synapse.tools.easycert.main(argv, outp=None)[source]

synapse.tools.feed module

synapse.tools.feed.addFeedData(core, outp, feedformat, debug=False, *paths, chunksize=1000, offset=0, viewiden=None)[source]
synapse.tools.feed.getItems(*paths)[source]
synapse.tools.feed.main(argv, outp=None)[source]
synapse.tools.feed.makeargparser()[source]

synapse.tools.genpkg module

synapse.tools.genpkg.chopSemVer(vers)[source]
synapse.tools.genpkg.getStormStr(fn)[source]
synapse.tools.genpkg.loadOpticFiles(pkgdef, path)[source]
synapse.tools.genpkg.loadPkgProto(path, opticdir=None, no_docs=False)[source]

Get a Storm Package definition from disk.

Parameters:
  • fp (str) – Path to the package .yaml file on disk.
  • opticdir (str) – Path to optional Optic module code to add to the Storm Package.
  • no_docs (bool) – If true, omit inline documentation content if it is not present on disk.
Returns:

A Storm package definition.

Return type:

dict

synapse.tools.genpkg.main(argv, outp=<synapse.lib.output.OutPut object>)[source]
synapse.tools.genpkg.tryLoadPkgProto(fp, opticdir=None)[source]

Try to get a Storm Package prototype from disk with or without inline documentation.

Parameters:
  • fp (str) – Path to the package .yaml file on disk.
  • opticdir (str) – Path to optional Optic module code to add to the Storm Package.
Returns:

A Storm package definition.

Return type:

dict

synapse.tools.guid module

synapse.tools.guid.main(argv, outp=None)[source]

synapse.tools.healthcheck module

synapse.tools.healthcheck.format_component(e, mesg: str) → dict[source]
synapse.tools.healthcheck.main(argv, outp=<synapse.lib.output.OutPut object>)[source]
synapse.tools.healthcheck.makeargparser()[source]
synapse.tools.healthcheck.serialize(ret)[source]

synapse.tools.json2mpk module

synapse.tools.json2mpk.getArgParser()[source]
synapse.tools.json2mpk.main(argv, outp=None)[source]

synapse.tools.pullfile module

synapse.tools.pullfile.main(argv, outp=None)[source]
synapse.tools.pullfile.setup()[source]

synapse.tools.pushfile module

synapse.tools.pushfile.main(argv, outp=None)[source]
synapse.tools.pushfile.makeargparser()[source]

synapse.tools.rstorm module

synapse.tools.rstorm.main(argv, outp=<synapse.lib.output.OutPut object>)[source]

synapse.tools.storm module

class synapse.tools.storm.ExportCmd(cli, **opts)[source]

Bases: synapse.tools.storm.StormCliCmd

Export the results of a storm query into a nodes file.

Example

// Export nodes to a file !export dnsa.nodes { inet:fqdn#mynodes -> inet:dns:a }

// Export nodes to a file and only include specific tags !export fqdn.nodes { inet:fqdn#mynodes } –include-tags footag

getArgParser()[source]
runCmdOpts(opts)[source]

Perform the command actions. Must be implemented by Cmd implementers.

Parameters:opts (dict) – Options dictionary.
class synapse.tools.storm.HelpCmd(cli, **opts)[source]

Bases: synapse.lib.cli.CmdHelp

List interpreter extended commands and display help output.

Example

!help foocmd

class synapse.tools.storm.PullFileCmd(cli, **opts)[source]

Bases: synapse.tools.storm.StormCliCmd

Download a file by sha256 and store it locally.

Example

!pullfile c00adfcc316f8b00772cdbce2505b9ea539d74f42861801eceb1017a44344ed3 /path/to/savefile

getArgParser()[source]
runCmdOpts(opts)[source]

Perform the command actions. Must be implemented by Cmd implementers.

Parameters:opts (dict) – Options dictionary.
class synapse.tools.storm.PushFileCmd(cli, **opts)[source]

Bases: synapse.tools.storm.StormCliCmd

Upload a file and create a file:bytes node.

Example

!pushfile /path/to/file

getArgParser()[source]
runCmdOpts(opts)[source]

Perform the command actions. Must be implemented by Cmd implementers.

Parameters:opts (dict) – Options dictionary.
class synapse.tools.storm.QuitCmd(cli, **opts)[source]

Bases: synapse.lib.cli.CmdQuit

Quit the current command line interpreter.

Example

!quit

class synapse.tools.storm.RunFileCmd(cli, **opts)[source]

Bases: synapse.tools.storm.StormCliCmd

Run a local storm file.

Example

!runfile /path/to/file.storm

getArgParser()[source]
runCmdOpts(opts)[source]

Perform the command actions. Must be implemented by Cmd implementers.

Parameters:opts (dict) – Options dictionary.
class synapse.tools.storm.StormCli[source]

Bases: synapse.lib.cli.Cli

handleErr(mesg)[source]
histfile = 'storm_history'
initCmdClasses()[source]
printf(mesg, addnl=True, color=None)[source]
runCmdLine(line, opts=None)[source]

Run a single command line.

Parameters:line (str) – Line to execute.

Examples

Execute the ‘woot’ command with the ‘help’ switch:

await cli.runCmdLine(‘woot –help’)
Returns:Arbitrary data from the cmd class.
Return type:object
storm(text, opts=None)[source]
class synapse.tools.storm.StormCliCmd(cli, **opts)[source]

Bases: synapse.lib.cli.Cmd

getArgParser()[source]
getCmdOpts(text)[source]

Use the _cmd_syntax def to split/parse/normalize the cmd line.

Parameters:text (str) – Command to process.

Notes

This is implemented independent of argparse (et al) due to the need for syntax aware argument splitting. Also, allows different split per command type

Returns:An opts dictionary.
Return type:dict
synapse.tools.storm.getArgParser()[source]
synapse.tools.storm.main(argv, outp=<synapse.lib.output.OutPut object>)[source]