diff --git a/changes/302e6db2488f498de9471bf36bf1c716.yaml b/changes/302e6db2488f498de9471bf36bf1c716.yaml new file mode 100644 index 00000000000..e39c22a0902 --- /dev/null +++ b/changes/302e6db2488f498de9471bf36bf1c716.yaml @@ -0,0 +1,5 @@ +--- +desc: Deprecate ``$lib.str.concat()``, ``$lib.str.format()``, and ``$lib.str.join()``. +prs: [] +type: deprecation +... diff --git a/changes/3fbb6fdc77579ce771bdd8ad32649f11.yaml b/changes/3fbb6fdc77579ce771bdd8ad32649f11.yaml new file mode 100644 index 00000000000..5c7acc7951a --- /dev/null +++ b/changes/3fbb6fdc77579ce771bdd8ad32649f11.yaml @@ -0,0 +1,7 @@ +--- +desc: Deprecated ``gen.it.av.scan.result``, ``gen.ps.contact.email``, ``gen.ou.org.hq``, + ``gen.ou.id.type``, and ``gen.ou.id.number``. +desc:literal: false +prs: [] +type: deprecation +... diff --git a/changes/59b29a495a8dcd4f6980bcc90fa5cbe2.yaml b/changes/59b29a495a8dcd4f6980bcc90fa5cbe2.yaml new file mode 100644 index 00000000000..3df8ee61a8f --- /dev/null +++ b/changes/59b29a495a8dcd4f6980bcc90fa5cbe2.yaml @@ -0,0 +1,6 @@ +--- +desc: Deprecated the synchronous use of ``synapse.telepath.openurl()`` and the ability + to make Telepath RPC calls from synchronous Python code. +prs: [] +type: deprecation +... diff --git a/changes/69a809b0a24b0d4778c03e016be17bee.yaml b/changes/69a809b0a24b0d4778c03e016be17bee.yaml new file mode 100644 index 00000000000..63a4e82f76f --- /dev/null +++ b/changes/69a809b0a24b0d4778c03e016be17bee.yaml @@ -0,0 +1,5 @@ +--- +desc: Deprecate ``inet:web:*`` forms and the ``inet:search:query:acct`` property. +prs: [] +type: deprecation +... diff --git a/changes/a85cf6e33ca144dc7c2b5f4954b4c609.yaml b/changes/a85cf6e33ca144dc7c2b5f4954b4c609.yaml new file mode 100644 index 00000000000..b71d49efcd6 --- /dev/null +++ b/changes/a85cf6e33ca144dc7c2b5f4954b4c609.yaml @@ -0,0 +1,5 @@ +--- +desc: Deprecated ``synapse.glob.sync()`` and ``synapse.glob.synchelp()`` APIs. +prs: [] +type: deprecation +... diff --git a/changes/ad1f8b6ce1e797a664dfdac59e942793.yaml b/changes/ad1f8b6ce1e797a664dfdac59e942793.yaml new file mode 100644 index 00000000000..e49e57c6f68 --- /dev/null +++ b/changes/ad1f8b6ce1e797a664dfdac59e942793.yaml @@ -0,0 +1,5 @@ +--- +desc: Deprecated ``synapse.coro.genrhelp()`` and ``synapse.glob.GenrHelp()`` APIs. +prs: [] +type: deprecation +... diff --git a/changes/df2f34f2ae5fc2dff8c46d1037531d6a.yaml b/changes/df2f34f2ae5fc2dff8c46d1037531d6a.yaml new file mode 100644 index 00000000000..408e8cb1cc0 --- /dev/null +++ b/changes/df2f34f2ae5fc2dff8c46d1037531d6a.yaml @@ -0,0 +1,6 @@ +--- +desc: Deprecated ``$lib.gen.*`` functions. +desc:literal: false +prs: [] +type: deprecation +... diff --git a/docs/synapse/userguides/storm_adv_vars.rstorm b/docs/synapse/userguides/storm_adv_vars.rstorm index 6ae83b7a7e3..0b2891f3a6c 100644 --- a/docs/synapse/userguides/storm_adv_vars.rstorm +++ b/docs/synapse/userguides/storm_adv_vars.rstorm @@ -359,11 +359,11 @@ You can assign an explicit, unchanging value to a variable. You can assign the value of a particular node property (secondary or universal) to a variable. -- **Secondary property:** Assign the ``:user`` property from an Internet-based account (``inet:web:acct``) to +- **Secondary property:** Assign the ``:user`` property from an Service based account (``inet:service:account``) to the variable ``$user``: -.. storm-pre:: [inet:web:acct=(twitter.com,hacks4cats) :email=ron@protonmail.com] -.. storm-cli:: inet:web:acct=(twitter.com,hacks4cats) $user=:user $lib.print($user) +.. storm-pre:: $twitter={[inet:service:platform=({'name': 'twitter'})]} [inet:service:account=({'platform': $twitter.value(), 'user': 'hacks4cats', 'email': 'ron@protonmail.com'})] +.. storm-cli:: inet:service:account:user=hacks4cats $user=:user $lib.print($user) - **Universal property:** Assign the ``.seen`` universal property from a DNS A node to the variable ``$time``: diff --git a/docs/synapse/userguides/storm_ref_type_specific.rstorm b/docs/synapse/userguides/storm_ref_type_specific.rstorm index 8081bc02e6b..639b5b7b9bf 100644 --- a/docs/synapse/userguides/storm_ref_type_specific.rstorm +++ b/docs/synapse/userguides/storm_ref_type_specific.rstorm @@ -1468,11 +1468,11 @@ Lift all organizations whose name starts with the word "Acme ": .. storm-cli:: ou:org:name^='acme ' -Filter a set of Internet accounts to those with usernames starting with 'matrix': - -.. storm-pre:: [ inet:web:acct=(twitter.com,matrixmaster) inet:web:acct=(twitter.com,matrixneo) ] -.. storm-cli:: inet:web:acct:site=twitter.com +:user^=matrix +Filter a set of Service accounts to those with usernames starting with 'matrix': +.. storm-pre:: $twitter={[inet:service:platform=({'name': 'twitter'})]} [ inet:service:account=({'platform': $twitter.value(), 'user': 'matrixmaster'}) inet:service:account=({'platform': $twitter.value(), 'user': 'matrixneo'}) ] +e:account=({'platform': $twitter.value(), 'user': 'matrixneo'}) ] +.. storm-cli:: inet:service:account:platform=({'name': 'twitter'}) +:user^=matrix Strings and string-derived types can also be lifted or filtered using the regular expression extended comparator ( ``~=``) (see :ref:`lift-regex` and :ref:`filter-regex`). diff --git a/synapse/glob.py b/synapse/glob.py index faab5cafe0f..278a8aa4023 100644 --- a/synapse/glob.py +++ b/synapse/glob.py @@ -2,6 +2,7 @@ import signal import asyncio import logging +import warnings import threading import faulthandler @@ -10,6 +11,11 @@ _glob_loop = None _glob_thrd = None +# TODO Remove me in 3xx - this is just to avoid a circular import on synapse.common +def _deprecated(name, curv='2.x', eolv='3.0.0'): + mesg = f'"{name}" is deprecated in {curv} and will be removed in {eolv}' + warnings.warn(mesg, DeprecationWarning) + return mesg def _asynciostacks(*args, **kwargs): # pragma: no cover ''' @@ -83,6 +89,7 @@ def sync(coro, timeout=None): Notes: This API is thread safe and should only be called by non-loop threads. ''' + _deprecated('synapse.glob.sync - synchronous wrapping of coroutines is not supported: {f.__name__}') loop = initloop() return asyncio.run_coroutine_threadsafe(coro, loop).result(timeout) @@ -115,6 +122,7 @@ def wrap(*args, **kwargs): coro = f(*args, **kwargs) if not iAmLoop(): + _deprecated('synapse.glob.synchelp - synchronous wrapping of coroutines is not supported: {f.__name__}') return sync(coro) return coro diff --git a/synapse/lib/coro.py b/synapse/lib/coro.py index 50bada66cb1..c58b81ce57d 100644 --- a/synapse/lib/coro.py +++ b/synapse/lib/coro.py @@ -112,7 +112,7 @@ async def timewait(self, timeout=None): async def event_wait(event: asyncio.Event, timeout=None): ''' - Wait on an an asyncio event with an optional timeout + Wait on an asyncio event with an optional timeout Returns: true if the event got set, False if timed out @@ -189,6 +189,7 @@ async def await_bg_tasks(timeout=None): class GenrHelp: def __init__(self, genr): + s_common.deprecated('synapse.coro.GenrHelp()') assert genr is not None self.genr = genr @@ -220,6 +221,7 @@ async def list(self): return [x async for x in self.genr] def genrhelp(f): + s_common.deprecated('synapse.coro.genrhelp()') @functools.wraps(f) def func(*args, **kwargs): return GenrHelp(f(*args, **kwargs)) diff --git a/synapse/lib/stormlib/gen.py b/synapse/lib/stormlib/gen.py index 6d98d46d48a..75d17bf63eb 100644 --- a/synapse/lib/stormlib/gen.py +++ b/synapse/lib/stormlib/gen.py @@ -7,18 +7,21 @@ class LibGen(s_stormtypes.Lib): ''' _storm_locals = ( {'name': 'orgByName', 'desc': 'Returns an ou:org by name, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the org.'}, ), 'returns': {'type': 'node', 'desc': 'An ou:org node with the given name.'}}}, {'name': 'orgHqByName', 'desc': 'Returns a ps:contact node for the ou:org, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the org.'}, ), 'returns': {'type': 'node', 'desc': 'A ps:contact node for the ou:org with the given name.'}}}, {'name': 'orgByFqdn', 'desc': 'Returns an ou:org node by FQDN, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'fqdn', 'type': 'str', 'desc': 'The FQDN of the org.'}, @@ -27,12 +30,14 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'An ou:org node with the given FQDN.'}}}, {'name': 'industryByName', 'desc': 'Returns an ou:industry by name, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the industry.'}, ), 'returns': {'type': 'node', 'desc': 'An ou:industry node with the given name.'}}}, {'name': 'newsByUrl', 'desc': 'Returns a media:news node by URL, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'url', 'type': 'inet:url', 'desc': 'The URL where the news is published.'}, @@ -41,12 +46,14 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'A media:news node with the given URL.'}}}, {'name': 'softByName', 'desc': 'Returns it:prod:soft node by name, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the software.'}, ), 'returns': {'type': 'node', 'desc': 'An it:prod:soft node with the given name.'}}}, {'name': 'vulnByCve', 'desc': 'Returns risk:vuln node by CVE and reporter, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'cve', 'type': 'str', 'desc': 'The CVE id.'}, @@ -58,6 +65,7 @@ class LibGen(s_stormtypes.Lib): 'returns': {'type': 'node', 'desc': 'A risk:vuln node with the given CVE.'}}}, {'name': 'riskThreat', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns a risk:threat node based on the threat and reporter names, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -67,6 +75,7 @@ class LibGen(s_stormtypes.Lib): 'returns': {'type': 'node', 'desc': 'A risk:threat node.'}}}, {'name': 'riskToolSoftware', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns a risk:tool:software node based on the tool and reporter names, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -76,6 +85,7 @@ class LibGen(s_stormtypes.Lib): 'returns': {'type': 'node', 'desc': 'A risk:tool:software node.'}}}, {'name': 'psContactByEmail', 'desc': 'Returns a ps:contact by deconflicting the type and email address.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'type', 'type': 'str', 'desc': 'The ps:contact:type property.'}, @@ -86,6 +96,7 @@ class LibGen(s_stormtypes.Lib): 'returns': {'type': 'node', 'desc': 'A ps:contact node.'}}}, {'name': 'polCountryByIso2', 'desc': 'Returns a pol:country node by deconflicting the :iso2 property.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'iso2', 'type': 'str', 'desc': 'The pol:country:iso2 property.'}, @@ -94,12 +105,14 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'A pol:country node.'}}}, {'name': 'langByName', 'desc': 'Returns a lang:language node by name, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the language.'}, ), 'returns': {'type': 'node', 'desc': 'A lang:language node with the given name.'}}}, {'name': 'langByCode', 'desc': 'Returns a lang:language node by language code, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The language code for the language.'}, @@ -108,6 +121,7 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'A lang:language node with the given code.'}}}, {'name': 'campaign', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns an ou:campaign node based on the campaign and reporter names, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -116,6 +130,7 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'An ou:campaign node.'}}}, {'name': 'itAvScanResultByTarget', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns an it:av:scan:result node by deconflicting with a target and signature name, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -131,12 +146,14 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'An it:av:scan:result node.'}}}, {'name': 'geoPlaceByName', 'desc': 'Returns a geo:place node by name, adding the node if it does not exist.', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( {'name': 'name', 'type': 'str', 'desc': 'The name of the place.'}, ), 'returns': {'type': 'node', 'desc': 'A geo:place node with the given name.'}}}, {'name': 'fileBytesBySha256', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns a file:bytes node by SHA256, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -146,6 +163,7 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'A file:bytes node with the given SHA256.'}}}, {'name': 'cryptoX509CertBySha256', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns a crypto:x509:cert node by SHA256, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -155,6 +173,7 @@ class LibGen(s_stormtypes.Lib): ), 'returns': {'type': 'node', 'desc': 'A crypto:x509:cert node with the given SHA256.'}}}, {'name': 'inetTlsServerCertByServerAndSha256', + 'deprecated': {'eolvers': '3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'desc': 'Returns an inet:tls:servercert node by server and SHA256, adding the node if it does not exist.', 'type': {'type': 'function', '_funcname': '_storm_query', 'args': ( @@ -511,6 +530,7 @@ class LibGen(s_stormtypes.Lib): { 'name': 'gen.ou.id.number', + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'descr': 'Lift (or create) an ou:id:number node based on the organization ID type and value.', 'cmdargs': ( ('type', {'help': 'The type of the organization ID.'}), @@ -520,6 +540,7 @@ class LibGen(s_stormtypes.Lib): }, { 'name': 'gen.ou.id.type', + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'descr': 'Lift (or create) an ou:id:type node based on the name of the type.', 'cmdargs': ( ('name', {'help': 'The friendly name of the organization ID type.'}), @@ -536,6 +557,7 @@ class LibGen(s_stormtypes.Lib): }, { 'name': 'gen.ou.org.hq', + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'descr': 'Lift (or create) the primary ps:contact node for the ou:org based on the organization name.', 'cmdargs': ( ('name', {'help': 'The name of the organization.'}), @@ -655,6 +677,7 @@ class LibGen(s_stormtypes.Lib): }, { 'name': 'gen.ps.contact.email', + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'descr': ''' Lift (or create) the ps:contact node by deconflicting the email and type. @@ -682,6 +705,7 @@ class LibGen(s_stormtypes.Lib): # todo: remove it:av:filehit example in 3.x.x { 'name': 'gen.it.av.scan.result', + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use dictionary constructor syntax instead.'}, 'descr': ''' Lift (or create) the it:av:scan:result node by deconflicting the target and signature name. diff --git a/synapse/lib/stormtypes.py b/synapse/lib/stormtypes.py index 75175de1760..4886b89307f 100644 --- a/synapse/lib/stormtypes.py +++ b/synapse/lib/stormtypes.py @@ -1988,7 +1988,7 @@ class LibStr(Lib): ''' _storm_locals = ( {'name': 'join', 'desc': 'Join items into a string using a separator.', - # 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use ``('').join($foo, $bar, $baz, ....)`` instead.'}, + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use ``('').join($foo, $bar, $baz, ....)`` instead.'}, 'type': {'type': 'function', '_funcname': 'join', 'args': ( {'name': 'sepr', 'type': 'str', 'desc': 'The separator used to join strings with.', }, @@ -1996,14 +1996,14 @@ class LibStr(Lib): ), 'returns': {'type': 'str', 'desc': 'The joined string.', }}}, {'name': 'concat', 'desc': 'Concatenate a set of strings together.', - # 'deprecated': {'eolvers': 'v3.0.0', 'mesg': "Use ``('').join($foo, $bar, $baz, ....)`` instead."}, + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': "Use ``('').join($foo, $bar, $baz, ....)`` instead."}, 'type': {'type': 'function', '_funcname': 'concat', 'args': ( {'name': '*args', 'type': 'any', 'desc': 'Items to join together.', }, ), 'returns': {'type': 'str', 'desc': 'The joined string.', }}}, {'name': 'format', 'desc': 'Format a text string.', - # 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use ``$mystr.format(foo=$bar)`` instead.'}, + 'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use ``$mystr.format(foo=$bar)`` instead.'}, 'type': {'type': 'function', '_funcname': 'format', 'args': ( {'name': 'text', 'type': 'str', 'desc': 'The base text string.', }, @@ -2014,9 +2014,9 @@ class LibStr(Lib): ) _storm_lib_path = ('str',) - # _lib_str_join_depr_mesg = '$lib.str.join(), use "$sepr.join($items)" instead.' - # _lib_str_concat_depr_mesg = "$lib.str.concat(), use ('').join($foo, $bar, $baz, ....) instead." - # _lib_str_format_depr_mesg = '$lib.str.format(), use "$mystr.format(foo=$bar)" instead.' + _lib_str_join_depr_mesg = '$lib.str.join(), use "$sepr.join($items)" instead.' + _lib_str_concat_depr_mesg = "$lib.str.concat(), use ('').join($foo, $bar, $baz, ....) instead." + _lib_str_format_depr_mesg = '$lib.str.format(), use "$mystr.format(foo=$bar)" instead.' def getObjLocals(self): return { @@ -2027,29 +2027,29 @@ def getObjLocals(self): @stormfunc(readonly=True) async def concat(self, *args): - # s_common.deprecated(self._lib_str_concat_depr_mesg) - # runt = s_scope.get('runt') - # if runt: - # await runt.snap.warnonce(self._lib_str_concat_depr_mesg) + s_common.deprecated(self._lib_str_concat_depr_mesg) + runt = s_scope.get('runt') + if runt: + await runt.snap.warnonce(self._lib_str_concat_depr_mesg) strs = [await tostr(a) for a in args] return ''.join(strs) @stormfunc(readonly=True) async def format(self, text, **kwargs): - # s_common.deprecated(self._lib_str_format_depr_mesg) - # runt = s_scope.get('runt') - # if runt: - # await runt.snap.warnonce(self._lib_str_format_depr_mesg) + s_common.deprecated(self._lib_str_format_depr_mesg) + runt = s_scope.get('runt') + if runt: + await runt.snap.warnonce(self._lib_str_format_depr_mesg) text = await kwarg_format(text, **kwargs) return text @stormfunc(readonly=True) async def join(self, sepr, items): - # s_common.deprecated(self._lib_str_join_depr_mesg) - # runt = s_scope.get('runt') - # if runt: - # await runt.snap.warnonce(self._lib_str_join_depr_mesg) + s_common.deprecated(self._lib_str_join_depr_mesg) + runt = s_scope.get('runt') + if runt: + await runt.snap.warnonce(self._lib_str_join_depr_mesg) strs = [await tostr(item) async for item in toiter(items)] return sepr.join(strs) diff --git a/synapse/models/inet.py b/synapse/models/inet.py index b8a1abd8cd1..4a95bf63af7 100644 --- a/synapse/models/inet.py +++ b/synapse/models/inet.py @@ -1419,64 +1419,74 @@ def getModelDefs(self): }), ('inet:web:acct', ('comp', {'fields': (('site', 'inet:fqdn'), ('user', 'inet:user')), 'sepr': '/'}), { - 'doc': 'An account with a given Internet-based site or service.', - 'ex': 'twitter.com/invisig0th' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:account.', }), ('inet:web:action', ('guid', {}), { - 'doc': 'An instance of an account performing an action at an Internet-based site or service.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:access.', }), ('inet:web:chprofile', ('guid', {}), { - 'doc': 'A change to a web account. Used to capture historical properties associated with ' - ' an account, as opposed to current data in the inet:web:acct node.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:access.', }), ('inet:web:file', ('comp', {'fields': (('acct', 'inet:web:acct'), ('file', 'file:bytes'))}), { - 'doc': 'A file posted by a web account.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:message and inet:service:message:attachment.' }), ('inet:web:attachment', ('guid', {}), { - 'doc': 'An instance of a file being sent to a web service by an account.'}), + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:message and inet:service:message:attachment.'}), ('inet:web:follows', ('comp', {'fields': (('follower', 'inet:web:acct'), ('followee', 'inet:web:acct'))}), { - 'doc': 'A web account follows or is connected to another web account.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:relationship.' }), ('inet:web:group', ('comp', {'fields': (('site', 'inet:fqdn'), ('id', 'inet:group')), 'sepr': '/'}), { - 'doc': 'A group hosted within or registered with a given Internet-based site or service.', - 'ex': 'somesite.com/mycoolgroup' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:group.', }), ('inet:web:logon', ('guid', {}), { - 'doc': 'An instance of an account authenticating to an Internet-based site or service.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:login.' }), ('inet:web:memb', ('comp', {'fields': (('acct', 'inet:web:acct'), ('group', 'inet:web:group'))}), { 'deprecated': True, - 'doc': 'Deprecated. Please use inet:web:member.' + 'doc': 'Deprecated. Please use inet:service:group:member', }), ('inet:web:member', ('guid', {}), { - 'doc': 'Represents a web account membership in a channel or group.', + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:channel:member or inet:service:group:member', }), ('inet:web:mesg', ('comp', {'fields': (('from', 'inet:web:acct'), ('to', 'inet:web:acct'), ('time', 'time'))}), { - 'doc': 'A message sent from one web account to another web account or channel.', - 'ex': '((twitter.com, invisig0th), (twitter.com, gobbles), 20041012130220)' + 'deprecated': True, + 'doc': 'Deprecated. Pleas use inet:service:message.', }), ('inet:web:post', ('guid', {}), { - 'doc': 'A post made by a web account.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:message.' }), ('inet:web:post:link', ('guid', {}), { - 'doc': 'A link contained within post text.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:message:link.' }), ('inet:web:instance', ('guid', {}), { - 'doc': 'An instance of a web service such as slack or discord.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:instance.' }), ('inet:web:channel', ('guid', {}), { - 'doc': 'A channel within a web service or instance such as slack or discord.' + 'deprecated': True, + 'doc': 'Deprecated. Please use inet:service:channel.' }), ('inet:web:hashtag', ('str', {'lower': True, 'strip': True, 'regex': r'^#[^\p{Z}#]+$'}), { @@ -2744,6 +2754,7 @@ def getModelDefs(self): 'doc': 'The time the web search was issued.', }), ('acct', ('inet:web:acct', {}), { + 'deprecated': True, 'doc': 'The account that the query was issued as.', }), ('host', ('it:host', {}), { diff --git a/synapse/telepath.py b/synapse/telepath.py index c7b01867ea2..8137e46e142 100644 --- a/synapse/telepath.py +++ b/synapse/telepath.py @@ -395,7 +395,7 @@ def __enter__(self): ''' if s_threads.iden() == self.tid: raise s_exc.SynErr(mesg='Use of synchronous context manager in async code') - + s_common.deprecated('synapse.telepath.Share - synchronous context manager usage.') self._ctxobj = self.schedCoroSafePend(self.__aenter__()) return self @@ -432,7 +432,7 @@ async def __aiter__(self): await self.fini() def __iter__(self): - + s_common.deprecated('synaspe.telepath.Proxy - synchronous generator use.') try: while not self.isfini: @@ -492,6 +492,7 @@ async def __aiter__(self): await asyncio.sleep(0) def __iter__(self): + s_common.deprecated('synaspe.telepath.Proxy - synchronous generator use.') genr = s_glob.sync(self.proxy.task(self.todo, name=self.share)) for item in genr: yield item @@ -824,6 +825,7 @@ def __enter__(self): ''' if s_threads.iden() == self.tid: raise s_exc.SynErr(mesg='Use of synchronous context manager in async code') + s_common.deprecated('synapse.telepath.Proxy - synchronous context manager usage.') self._ctxobj = self.schedCoroSafePend(self.__aenter__()) return self diff --git a/synapse/tests/test_model_syn.py b/synapse/tests/test_model_syn.py index 84b90b17861..559154c5cc6 100644 --- a/synapse/tests/test_model_syn.py +++ b/synapse/tests/test_model_syn.py @@ -738,20 +738,29 @@ async def test_syn_cmd_runts(self): self.eq(nodes[4].get('deprecated:mesg'), 'Please use ``ohhai``.') nodes = await core.nodes('syn:cmd:deprecated') - self.len(5, nodes) - self.sorteq(['deprvers', 'deprdate', 'deprmesg', 'ps.list', 'ps.kill'], [k.ndef[1] for k in nodes]) + self.len(10, nodes) + self.sorteq([ + 'deprvers', 'deprdate', 'deprmesg', 'ps.list', 'ps.kill', 'gen.it.av.scan.result', + 'gen.ou.id.number', 'gen.ou.id.type', 'gen.ps.contact.email', 'gen.ou.org.hq', + ], [k.ndef[1] for k in nodes]) nodes = await core.nodes('syn:cmd:deprecated:version') - self.len(3, nodes) - self.sorteq(['deprvers', 'ps.list', 'ps.kill'], [k.ndef[1] for k in nodes]) + self.len(8, nodes) + self.sorteq([ + 'deprvers', 'ps.list', 'ps.kill', 'gen.it.av.scan.result', + 'gen.ou.id.number', 'gen.ou.id.type', 'gen.ps.contact.email', 'gen.ou.org.hq', + ], [k.ndef[1] for k in nodes]) nodes = await core.nodes('syn:cmd:deprecated:date') self.len(2, nodes) self.sorteq(['deprdate', 'deprmesg'], [k.ndef[1] for k in nodes]) nodes = await core.nodes('syn:cmd:deprecated:mesg') - self.len(3, nodes) - self.sorteq(['deprmesg', 'ps.list', 'ps.kill'], [k.ndef[1] for k in nodes]) + self.len(8, nodes) + self.sorteq([ + 'deprmesg', 'ps.list', 'ps.kill', 'gen.it.av.scan.result', + 'gen.ou.id.number', 'gen.ou.id.type', 'gen.ps.contact.email', 'gen.ou.org.hq', + ], [k.ndef[1] for k in nodes]) # Pivot from cmds to their forms nodes = await core.nodes('syn:cmd=foobar -> *') diff --git a/synapse/tests/utils.py b/synapse/tests/utils.py index dce35e2fc36..de858ad36d6 100644 --- a/synapse/tests/utils.py +++ b/synapse/tests/utils.py @@ -1066,12 +1066,13 @@ class SynTest(unittest.TestCase): ''' def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs) - for s in dir(self): attr = getattr(self, s, None) # If s is an instance method and starts with 'test_', synchelp wrap it if inspect.iscoroutinefunction(attr) and s.startswith('test_') and inspect.ismethod(attr): setattr(self, s, s_glob.synchelp(attr)) + s_common.deprecated('synchelp decorated test methods are deprecated. SynTest in Synapse 3.x.x ' + 'uses unittest.IsolatedAsyncioTestCase to run async test methods.') def checkNode(self, node, expected): ex_ndef, ex_props = expected