commit 1451ee967a3d73040f56f9395c9749eb723a92da Author: Damian Johnson atagar@torproject.org Date: Sun May 26 11:20:20 2019 -0700
Fix 'invalid escape sequence' warnings
Python 3.6 is deprecating invalid escape sequences [1][2], and as such pycodestyle 2.5.0 generates warnings for them [3]...
* /home/atagar/Desktop/stem/stem/descriptor/bandwidth_file.py line 264 - W605 invalid escape sequence '*' | :var dict measurements: ***** mapping of relay fingerprints to their line 267 - W605 invalid escape sequence '*' | :var dict header: ***** header metadata line 268 - W605 invalid escape sequence '*' | :var datetime timestamp: ***** time when these metrics were published line 269 - W605 invalid escape sequence '*' | :var str version: ***** document format version line 294 - W605 invalid escape sequence '*' | ***** attribute is either required when we're parsed with validation or has
The trick is that there's two layers of escaping at play...
* For Python '*' is not a valid escape sequence, and as such as a string it's equivilant to '\*'...
>>> '*' == '\*' True
* For Sphinx and regexes '*' is meaningful. All the 'invalid escapes' cited by pycodestyle are for those.
Simple to fix. This replaces all invalid escape sequences with their valid counterpart.
[1] https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior [2] https://bugs.python.org/issue27364 [3] https://trac.torproject.org/projects/tor/ticket/27270 --- cache_fallback_directories.py | 2 +- cache_manual.py | 2 +- docs/change_log.rst | 1 + stem/connection.py | 18 ++--- stem/descriptor/__init__.py | 4 +- stem/descriptor/bandwidth_file.py | 10 +-- stem/descriptor/extrainfo_descriptor.py | 28 +++---- stem/descriptor/hidden_service_descriptor.py | 16 ++-- stem/descriptor/microdescriptor.py | 12 +-- stem/descriptor/networkstatus.py | 112 +++++++++++++-------------- stem/descriptor/router_status_entry.py | 42 +++++----- stem/descriptor/server_descriptor.py | 52 ++++++------- stem/descriptor/tordnsel.py | 10 +-- stem/directory.py | 18 ++--- stem/exit_policy.py | 6 +- stem/process.py | 2 +- stem/response/__init__.py | 2 +- stem/response/events.py | 2 +- stem/util/connection.py | 26 +++---- stem/util/system.py | 2 +- stem/util/test_tools.py | 2 +- test/output.py | 6 +- test/task.py | 2 +- test/unit/directory/fallback.py | 2 +- test/unit/installation.py | 2 +- 25 files changed, 191 insertions(+), 190 deletions(-)
diff --git a/cache_fallback_directories.py b/cache_fallback_directories.py index 137ce1a0..7827f712 100755 --- a/cache_fallback_directories.py +++ b/cache_fallback_directories.py @@ -19,7 +19,7 @@ except ImportError: import urllib2 as urllib
GITWEB_MAN_LOG = 'https://gitweb.torproject.org/tor.git/log/src/app/config/fallback_dirs.inc' -FALLBACK_DIR_LINK = "href='/tor.git/commit/src/app/config/fallback_dirs.inc?id=([^']*)'" +FALLBACK_DIR_LINK = "href='/tor.git/commit/src/app/config/fallback_dirs.inc\?id=([^']*)'"
if __name__ == '__main__': try: diff --git a/cache_manual.py b/cache_manual.py index 4c32725c..8e198226 100755 --- a/cache_manual.py +++ b/cache_manual.py @@ -19,7 +19,7 @@ except ImportError: import urllib2 as urllib
GITWEB_MAN_LOG = 'https://gitweb.torproject.org/tor.git/log/doc/tor.1.txt' -MAN_LOG_LINK = "href='/tor.git/commit/doc/tor.1.txt?id=([^']*)'" +MAN_LOG_LINK = "href='/tor.git/commit/doc/tor.1.txt\?id=([^']*)'"
if __name__ == '__main__': try: diff --git a/docs/change_log.rst b/docs/change_log.rst index cdb9e450..fc09eabc 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -80,6 +80,7 @@ The following are only available within Stem's `git repository * **Utilities**
* :func:`~stem.util.tor_tools.is_valid_hidden_service_address` now provides *true* if a v3 hidden servie address + * Fixed 'invalid escape sequence' python 3.6 warnings (:trac:`27270`)
* **Website**
diff --git a/stem/connection.py b/stem/connection.py index 2283dc58..8a64c887 100644 --- a/stem/connection.py +++ b/stem/connection.py @@ -474,49 +474,49 @@ def authenticate(controller, password = None, chroot_path = None, protocolinfo_r Tor allows for authentication by reading it a cookie file, but we can't read that file (probably due to permissions).
- * *****:class:`stem.connection.IncorrectCookieValue` + * **\***:class:`stem.connection.IncorrectCookieValue`
Tor allows for authentication by reading it a cookie file, but rejected the contents of that file.
- * *****:class:`stem.connection.AuthChallengeUnsupported` + * **\***:class:`stem.connection.AuthChallengeUnsupported`
Tor doesn't recognize the AUTHCHALLENGE command. This is probably a Tor version prior to SAFECOOKIE being implement, but this exception shouldn't arise because we won't attempt SAFECOOKIE auth unless Tor claims to support it.
- * *****:class:`stem.connection.UnrecognizedAuthChallengeMethod` + * **\***:class:`stem.connection.UnrecognizedAuthChallengeMethod`
Tor couldn't recognize the AUTHCHALLENGE method Stem sent to it. This shouldn't happen at all.
- * *****:class:`stem.connection.InvalidClientNonce` + * **\***:class:`stem.connection.InvalidClientNonce`
Tor says that the client nonce provided by Stem during the AUTHCHALLENGE process is invalid.
- * *****:class:`stem.connection.AuthSecurityFailure` + * **\***:class:`stem.connection.AuthSecurityFailure`
Nonce value provided by the server was invalid.
- * *****:class:`stem.connection.OpenAuthRejected` + * **\***:class:`stem.connection.OpenAuthRejected`
Tor says that it allows for authentication without any credentials, but then rejected our authentication attempt.
- * *****:class:`stem.connection.MissingAuthInfo` + * **\***:class:`stem.connection.MissingAuthInfo`
Tor provided us with a PROTOCOLINFO reply that is technically valid, but missing the information we need to authenticate.
- * *****:class:`stem.connection.AuthenticationFailure` + * **\***:class:`stem.connection.AuthenticationFailure`
There are numerous other ways that authentication could have failed including socket failures, malformed controller responses, etc. These mostly constitute transient failures or bugs.
- ***** In practice it is highly unusual for this to occur, being more of a + **\*** In practice it is highly unusual for this to occur, being more of a theoretical possibility rather than something you should expect. It's fine to treat these as errors. If you have a use case where this commonly happens, please file a ticket on 'trac.torproject.org'. diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py index 40df1391..ef6530ed 100644 --- a/stem/descriptor/__init__.py +++ b/stem/descriptor/__init__.py @@ -307,7 +307,7 @@ def parse_file(descriptor_file, descriptor_type = None, validate = False, docume
initial_position = descriptor_file.tell() first_line = stem.util.str_tools._to_unicode(descriptor_file.readline().strip()) - metrics_header_match = re.match('^@type (\S+) (\d+).(\d+)$', first_line) + metrics_header_match = re.match('^@type (\S+) (\d+).(\d+)$', first_line)
if not metrics_header_match: descriptor_file.seek(initial_position) @@ -320,7 +320,7 @@ def parse_file(descriptor_file, descriptor_type = None, validate = False, docume descriptor_file = NewlineNormalizer(descriptor_file)
if descriptor_type is not None: - descriptor_type_match = re.match('^(\S+) (\d+).(\d+)$', descriptor_type) + descriptor_type_match = re.match('^(\S+) (\d+).(\d+)$', descriptor_type)
if descriptor_type_match: desc_type, major_version, minor_version = descriptor_type_match.groups() diff --git a/stem/descriptor/bandwidth_file.py b/stem/descriptor/bandwidth_file.py index 1f000f50..9fd44859 100644 --- a/stem/descriptor/bandwidth_file.py +++ b/stem/descriptor/bandwidth_file.py @@ -261,12 +261,12 @@ class BandwidthFile(Descriptor): """ Tor bandwidth authority measurements.
- :var dict measurements: ***** mapping of relay fingerprints to their + :var dict measurements: **\*** mapping of relay fingerprints to their bandwidth measurement metadata
- :var dict header: ***** header metadata - :var datetime timestamp: ***** time when these metrics were published - :var str version: ***** document format version + :var dict header: **\*** header metadata + :var datetime timestamp: **\*** time when these metrics were published + :var str version: **\*** document format version
:var str software: application that generated these metrics :var str software_version: version of the application that generated these metrics @@ -291,7 +291,7 @@ class BandwidthFile(Descriptor): :var RecentStats recent_stats: statistical information collected over the last 'data_period' (by default five days)
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined """
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py index 7f13e32c..82e3154f 100644 --- a/stem/descriptor/extrainfo_descriptor.py +++ b/stem/descriptor/extrainfo_descriptor.py @@ -16,7 +16,7 @@ Extra-info descriptors are available from a few sources...
* If you have 'DownloadExtraInfo 1' in your torrc...
- * control port via 'GETINFO extra-info/digest/*' queries + * control port via 'GETINFO extra-info/digest/\*' queries * the 'cached-extrainfo' file in tor's data directory
* Archived descriptors provided by `CollecTor https://metrics.torproject.org/collector.html`_. @@ -164,8 +164,8 @@ SINGLE_FIELDS = ( 'exit-streams-opened', )
-_timestamp_re = re.compile('^(.*) (([0-9]+) s)( .*)?$') -_locale_re = re.compile('^[a-zA-Z0-9?]{2}$') +_timestamp_re = re.compile('^(.*) \(([0-9]+) s\)( .*)?$') +_locale_re = re.compile('^[a-zA-Z0-9\?]{2}$')
def _parse_file(descriptor_file, is_bridge = False, validate = False, **kwargs): @@ -572,12 +572,12 @@ class ExtraInfoDescriptor(Descriptor): """ Extra-info descriptor document.
- :var str nickname: ***** relay's nickname - :var str fingerprint: ***** identity key fingerprint - :var datetime published: ***** time in UTC when this descriptor was made + :var str nickname: **\*** relay's nickname + :var str fingerprint: **\*** identity key fingerprint + :var datetime published: **\*** time in UTC when this descriptor was made :var str geoip_db_digest: sha1 of the geoIP database file for IPv4 addresses :var str geoip6_db_digest: sha1 of the geoIP database file for IPv6 addresses - :var dict transport: ***** mapping of transport methods to their (address, + :var dict transport: **\*** mapping of transport methods to their (address, port, args) tuple, these usually appear on bridges in which case all of those are **None**
@@ -663,13 +663,13 @@ class ExtraInfoDescriptor(Descriptor):
:var datetime hs_stats_end: end of the sampling interval :var int hs_rend_cells: rounded count of the RENDEZVOUS1 cells seen - :var int hs_rend_cells_attr: ***** attributes provided for the hs_rend_cells + :var int hs_rend_cells_attr: **\*** attributes provided for the hs_rend_cells :var int hs_dir_onions_seen: rounded count of the identities seen - :var int hs_dir_onions_seen_attr: ***** attributes provided for the hs_dir_onions_seen + :var int hs_dir_onions_seen_attr: **\*** attributes provided for the hs_dir_onions_seen
**Padding Count Attributes:**
- :var dict padding_counts: ***** padding parameters + :var dict padding_counts: **\*** padding parameters :var datetime padding_counts_end: end of the period when padding data is being collected :var int padding_counts_interval: length in seconds of the interval
@@ -683,7 +683,7 @@ class ExtraInfoDescriptor(Descriptor): :var dict ip_versions: mapping of ip protocols to a rounded count for the number of users :var dict ip_versions: mapping of ip transports to a count for the number of users
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined
.. versionchanged:: 1.4.0 @@ -906,14 +906,14 @@ class ExtraInfoDescriptor(Descriptor): class RelayExtraInfoDescriptor(ExtraInfoDescriptor): """ Relay extra-info descriptor, constructed from data such as that provided by - 'GETINFO extra-info/digest/*', cached descriptors, and metrics + 'GETINFO extra-info/digest/\*', cached descriptors, and metrics (`specification https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt`_).
:var ed25519_certificate str: base64 encoded ed25519 certificate :var ed25519_signature str: signature of this document using ed25519 - :var str signature: ***** signature for this extrainfo descriptor + :var str signature: **\*** signature for this extrainfo descriptor
- ***** attribute is required when we're parsed with validation + **\*** attribute is required when we're parsed with validation
.. versionchanged:: 1.5.0 Added the ed25519_certificate and ed25519_signature attributes. diff --git a/stem/descriptor/hidden_service_descriptor.py b/stem/descriptor/hidden_service_descriptor.py index bd35a19d..1b7f2cc3 100644 --- a/stem/descriptor/hidden_service_descriptor.py +++ b/stem/descriptor/hidden_service_descriptor.py @@ -185,15 +185,15 @@ class HiddenServiceDescriptor(Descriptor): """ Hidden service descriptor.
- :var str descriptor_id: ***** identifier for this descriptor, this is a base32 hash of several fields - :var int version: ***** hidden service descriptor version - :var str permanent_key: ***** long term key of the hidden service - :var str secret_id_part: ***** hash of the time period, cookie, and replica + :var str descriptor_id: **\*** identifier for this descriptor, this is a base32 hash of several fields + :var int version: **\*** hidden service descriptor version + :var str permanent_key: **\*** long term key of the hidden service + :var str secret_id_part: **\*** hash of the time period, cookie, and replica values so our descriptor_id can be validated - :var datetime published: ***** time in UTC when this descriptor was made - :var list protocol_versions: ***** list of **int** versions that are supported when establishing a connection + :var datetime published: **\*** time in UTC when this descriptor was made + :var list protocol_versions: **\*** list of **int** versions that are supported when establishing a connection :var str introduction_points_encoded: raw introduction points blob - :var list introduction_points_auth: ***** tuples of the form + :var list introduction_points_auth: **\*** tuples of the form (auth_method, auth_data) for our introduction_points_content (**deprecated**, always **[]**) :var bytes introduction_points_content: decoded introduction-points content @@ -201,7 +201,7 @@ class HiddenServiceDescriptor(Descriptor): encrypted :var str signature: signature of the descriptor content
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined
.. versionchanged:: 1.6.0 diff --git a/stem/descriptor/microdescriptor.py b/stem/descriptor/microdescriptor.py index 4703c914..de125f65 100644 --- a/stem/descriptor/microdescriptor.py +++ b/stem/descriptor/microdescriptor.py @@ -197,14 +197,14 @@ class Microdescriptor(Descriptor): Microdescriptor (`descriptor specification https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt`_)
- :var str onion_key: ***** key used to encrypt EXTEND cells + :var str onion_key: **\*** key used to encrypt EXTEND cells :var str ntor_onion_key: base64 key used to encrypt EXTEND in the ntor protocol - :var list or_addresses: ***** alternative for our address/or_port attributes, each + :var list or_addresses: **\*** alternative for our address/or_port attributes, each entry is a tuple of the form (address (**str**), port (**int**), is_ipv6 (**bool**)) - :var list family: ***** nicknames or fingerprints of declared family - :var stem.exit_policy.MicroExitPolicy exit_policy: ***** relay's exit policy - :var stem.exit_policy.MicroExitPolicy exit_policy_v6: ***** exit policy for IPv6 + :var list family: **\*** nicknames or fingerprints of declared family + :var stem.exit_policy.MicroExitPolicy exit_policy: **\*** relay's exit policy + :var stem.exit_policy.MicroExitPolicy exit_policy_v6: **\*** exit policy for IPv6 :var hash identifiers: mapping of key types (like rsa1024 or ed25519) to their base64 encoded identity, this is only used for collision prevention (:trac:`11743`) @@ -215,7 +215,7 @@ class Microdescriptor(Descriptor): :var str identifier_type: identity digest key type (**deprecated**, use identifiers instead)
- ***** attribute is required when we're parsed with validation + **\*** attribute is required when we're parsed with validation
.. versionchanged:: 1.1.0 Added the identifier and identifier_type attributes. diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py index e970dc73..b0589f2a 100644 --- a/stem/descriptor/networkstatus.py +++ b/stem/descriptor/networkstatus.py @@ -538,24 +538,24 @@ class NetworkStatusDocumentV2(NetworkStatusDocument): :var dict routers: fingerprints to :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV2` contained in the document
- :var int version: ***** document version + :var int version: **\*** document version
- :var str hostname: ***** hostname of the authority - :var str address: ***** authority's IP address - :var int dir_port: ***** authority's DirPort - :var str fingerprint: ***** authority's fingerprint - :var str contact: ***** authority's contact information - :var str signing_key: ***** authority's public signing key + :var str hostname: **\*** hostname of the authority + :var str address: **\*** authority's IP address + :var int dir_port: **\*** authority's DirPort + :var str fingerprint: **\*** authority's fingerprint + :var str contact: **\*** authority's contact information + :var str signing_key: **\*** authority's public signing key
:var list client_versions: list of recommended client tor version strings :var list server_versions: list of recommended server tor version strings - :var datetime published: ***** time when the document was published - :var list options: ***** list of things that this authority decides + :var datetime published: **\*** time when the document was published + :var list options: **\*** list of things that this authority decides
- :var str signing_authority: ***** name of the authority signing the document - :var str signature: ***** authority's signature for the document + :var str signing_authority: **\*** name of the authority signing the document + :var str signature: **\*** authority's signature for the document
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined """
@@ -943,27 +943,27 @@ class NetworkStatusDocumentV3(NetworkStatusDocument): :var dict routers: fingerprint to :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3` mapping for relays contained in the document
- :var int version: ***** document version - :var str version_flavor: ***** flavor associated with the document (such as 'ns' or 'microdesc') - :var bool is_consensus: ***** **True** if the document is a consensus - :var bool is_vote: ***** **True** if the document is a vote - :var bool is_microdescriptor: ***** **True** if this is a microdescriptor + :var int version: **\*** document version + :var str version_flavor: **\*** flavor associated with the document (such as 'ns' or 'microdesc') + :var bool is_consensus: **\*** **True** if the document is a consensus + :var bool is_vote: **\*** **True** if the document is a vote + :var bool is_microdescriptor: **\*** **True** if this is a microdescriptor flavored document, **False** otherwise - :var datetime valid_after: ***** time when the consensus became valid - :var datetime fresh_until: ***** time when the next consensus should be produced - :var datetime valid_until: ***** time when this consensus becomes obsolete - :var int vote_delay: ***** number of seconds allowed for collecting votes + :var datetime valid_after: **\*** time when the consensus became valid + :var datetime fresh_until: **\*** time when the next consensus should be produced + :var datetime valid_until: **\*** time when this consensus becomes obsolete + :var int vote_delay: **\*** number of seconds allowed for collecting votes from all authorities - :var int dist_delay: ***** number of seconds allowed for collecting + :var int dist_delay: **\*** number of seconds allowed for collecting signatures from all authorities :var list client_versions: list of recommended client tor versions :var list server_versions: list of recommended server tor versions - :var list packages: ***** list of :data:`~stem.descriptor.networkstatus.PackageVersion` entries - :var list known_flags: ***** list of :data:`~stem.Flag` for the router's flags - :var dict params: ***** dict of parameter(**str**) => value(**int**) mappings - :var list directory_authorities: ***** list of :class:`~stem.descriptor.networkstatus.DirectoryAuthority` + :var list packages: **\*** list of :data:`~stem.descriptor.networkstatus.PackageVersion` entries + :var list known_flags: **\*** list of :data:`~stem.Flag` for the router's flags + :var dict params: **\*** dict of parameter(**str**) => value(**int**) mappings + :var list directory_authorities: **\*** list of :class:`~stem.descriptor.networkstatus.DirectoryAuthority` objects that have generated this document - :var list signatures: ***** :class:`~stem.descriptor.networkstatus.DocumentSignature` + :var list signatures: **\*** :class:`~stem.descriptor.networkstatus.DocumentSignature` of the authorities that have signed the document
**Consensus Attributes:** @@ -985,7 +985,7 @@ class NetworkStatusDocumentV3(NetworkStatusDocument):
:var list consensus_methods: list of ints for the supported method versions :var datetime published: time when the document was published - :var dict flag_thresholds: ***** mapping of internal performance thresholds used while making the vote, values are **ints** or **floats** + :var dict flag_thresholds: **\*** mapping of internal performance thresholds used while making the vote, values are **ints** or **floats**
:var dict recommended_client_protocols: recommended protocols for clients :var dict recommended_relay_protocols: recommended protocols for relays @@ -997,7 +997,7 @@ class NetworkStatusDocumentV3(NetworkStatusDocument): to generate this vote, this is a mapping of hash functions to their resulting digest value
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as None if undefined
.. versionchanged:: 1.4.0 @@ -1519,13 +1519,13 @@ class DirectoryAuthority(Descriptor): * The authority's nickname ends with '-legacy'. * There's no **contact** or **vote_digest** attribute.
- :var str nickname: ***** authority's nickname - :var str v3ident: ***** identity key fingerprint used to sign votes and consensus - :var str hostname: ***** hostname of the authority - :var str address: ***** authority's IP address - :var int dir_port: ***** authority's DirPort - :var int or_port: ***** authority's ORPort - :var bool is_legacy: ***** if the authority's using the legacy format + :var str nickname: **\*** authority's nickname + :var str v3ident: **\*** identity key fingerprint used to sign votes and consensus + :var str hostname: **\*** hostname of the authority + :var str address: **\*** authority's IP address + :var int dir_port: **\*** authority's DirPort + :var int or_port: **\*** authority's ORPort + :var bool is_legacy: **\*** if the authority's using the legacy format :var str contact: contact information, this is included if is_legacy is **False**
**Consensus Attributes:** @@ -1535,12 +1535,12 @@ class DirectoryAuthority(Descriptor): **Vote Attributes:**
:var str legacy_dir_key: fingerprint of and obsolete identity key - :var stem.descriptor.networkstatus.KeyCertificate key_certificate: ***** + :var stem.descriptor.networkstatus.KeyCertificate key_certificate: **\*** authority's key certificate
- :var bool is_shared_randomness_participate: ***** **True** if this authority + :var bool is_shared_randomness_participate: **\*** **True** if this authority participates in establishing a shared random value, **False** otherwise - :var list shared_randomness_commitments: ***** list of + :var list shared_randomness_commitments: **\*** list of :data:`~stem.descriptor.networkstatus.SharedRandomnessCommitment` entries :var int shared_randomness_previous_reveal_count: number of commitments used to generate the last shared random value @@ -1551,7 +1551,7 @@ class DirectoryAuthority(Descriptor): :var str shared_randomness_current_value: base64 encoded current shared random value
- ***** mandatory attribute + **\*** mandatory attribute
.. versionchanged:: 1.4.0 Renamed our 'fingerprint' attribute to 'v3ident' (prior attribute exists @@ -1734,19 +1734,19 @@ class KeyCertificate(Descriptor): """ Directory key certificate for a v3 network status document.
- :var int version: ***** version of the key certificate + :var int version: **\*** version of the key certificate :var str address: authority's IP address :var int dir_port: authority's DirPort - :var str fingerprint: ***** authority's fingerprint - :var str identity_key: ***** long term authority identity key - :var datetime published: ***** time when this key was generated - :var datetime expires: ***** time after which this key becomes invalid - :var str signing_key: ***** directory server's public signing key + :var str fingerprint: **\*** authority's fingerprint + :var str identity_key: **\*** long term authority identity key + :var datetime published: **\*** time when this key was generated + :var datetime expires: **\*** time after which this key becomes invalid + :var str signing_key: **\*** directory server's public signing key :var str crosscert: signature made using certificate's signing key - :var str certification: ***** signature of this key certificate signed with + :var str certification: **\*** signature of this key certificate signed with the identity key
- ***** mandatory attribute + **\*** mandatory attribute """
TYPE_ANNOTATION_NAME = 'dir-key-certificate-3' @@ -1887,20 +1887,20 @@ class DetachedSignature(Descriptor):
.. versionadded:: 1.8.0
- :var str consensus_digest: ***** digest of the consensus being signed - :var datetime valid_after: ***** time when the consensus became valid - :var datetime fresh_until: ***** time when the next consensus should be produced - :var datetime valid_until: ***** time when this consensus becomes obsolete - :var list additional_digests: ***** + :var str consensus_digest: **\*** digest of the consensus being signed + :var datetime valid_after: **\*** time when the consensus became valid + :var datetime fresh_until: **\*** time when the next consensus should be produced + :var datetime valid_until: **\*** time when this consensus becomes obsolete + :var list additional_digests: **\*** :class:`~stem.descriptor.networkstatus.DocumentDigest` for additional consensus flavors - :var list additional_signatures: ***** + :var list additional_signatures: **\*** :class:`~stem.descriptor.networkstatus.DocumentSignature` for additional consensus flavors - :var list signatures: ***** :class:`~stem.descriptor.networkstatus.DocumentSignature` + :var list signatures: **\*** :class:`~stem.descriptor.networkstatus.DocumentSignature` of the authorities that have signed the document
- ***** mandatory attribute + **\*** mandatory attribute """
TYPE_ANNOTATION_NAME = 'detached-signature-3' diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py index 7d75d40d..344c5697 100644 --- a/stem/descriptor/router_status_entry.py +++ b/stem/descriptor/router_status_entry.py @@ -6,7 +6,7 @@ Parsing for router status entries, the information for individual routers within a network status document. This information is provided from a few sources...
-* control port via 'GETINFO ns/*' and 'GETINFO md/*' queries +* control port via 'GETINFO ns/\*' and 'GETINFO md/\*' queries * router entries in a network status document, like the cached-consensus
**Module Overview:** @@ -393,16 +393,16 @@ class RouterStatusEntry(Descriptor): Information about an individual router stored within a network status document. This is the common parent for concrete status entry types.
- :var stem.descriptor.networkstatus.NetworkStatusDocument document: ***** document that this descriptor came from + :var stem.descriptor.networkstatus.NetworkStatusDocument document: **\*** document that this descriptor came from
- :var str nickname: ***** router's nickname - :var str fingerprint: ***** router's fingerprint - :var datetime published: ***** router's publication - :var str address: ***** router's IP address - :var int or_port: ***** router's ORPort - :var int dir_port: ***** router's DirPort + :var str nickname: **\*** router's nickname + :var str fingerprint: **\*** router's fingerprint + :var datetime published: **\*** router's publication + :var str address: **\*** router's IP address + :var int or_port: **\*** router's ORPort + :var int dir_port: **\*** router's DirPort
- :var list flags: ***** list of :data:`~stem.Flag` associated with the relay + :var list flags: **\*** list of :data:`~stem.Flag` associated with the relay
:var stem.version.Version version: parsed version of tor, this is **None** if the relay's using a new versioning scheme @@ -509,9 +509,9 @@ class RouterStatusEntryV2(RouterStatusEntry): Information about an individual router stored within a version 2 network status document.
- :var str digest: ***** router's upper-case hex digest + :var str digest: **\*** router's upper-case hex digest
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined """
@@ -543,11 +543,11 @@ class RouterStatusEntryV3(RouterStatusEntry): Information about an individual router stored within a version 3 network status document.
- :var list or_addresses: ***** relay's OR addresses, this is a tuple listing + :var list or_addresses: **\*** relay's OR addresses, this is a tuple listing of the form (address (**str**), port (**int**), is_ipv6 (**bool**)) :var str identifier_type: identity digest key type :var str identifier: base64 encoded identity digest - :var str digest: ***** router's upper-case hex digest + :var str digest: **\*** router's upper-case hex digest
:var int bandwidth: bandwidth measured to be available by the relay, this is an arbitrary units (currently kilobytes per second) heuristic generated by @@ -555,17 +555,17 @@ class RouterStatusEntryV3(RouterStatusEntry): :var int measured: *bandwidth* vote provided by a bandwidth authority :var bool is_unmeasured: *bandwidth* measurement isn't based on three or more measurements - :var list unrecognized_bandwidth_entries: ***** bandwidth weighting + :var list unrecognized_bandwidth_entries: **\*** bandwidth weighting information that isn't yet recognized
:var stem.exit_policy.MicroExitPolicy exit_policy: router's exit policy :var dict protocols: mapping of protocols to their supported versions
- :var list microdescriptor_hashes: ***** tuples of two values, the list of + :var list microdescriptor_hashes: **\*** tuples of two values, the list of consensus methods for generating a set of digests and the 'algorithm => digest' mappings
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined
.. versionchanged:: 1.5.0 @@ -625,19 +625,19 @@ class RouterStatusEntryMicroV3(RouterStatusEntry): Information about an individual router stored within a microdescriptor flavored network status document.
- :var list or_addresses: ***** relay's OR addresses, this is a tuple listing + :var list or_addresses: **\*** relay's OR addresses, this is a tuple listing of the form (address (**str**), port (**int**), is_ipv6 (**bool**)) :var int bandwidth: bandwidth claimed by the relay (in kb/s) :var int measured: bandwidth measured to be available by the relay :var bool is_unmeasured: bandwidth measurement isn't based on three or more measurements - :var list unrecognized_bandwidth_entries: ***** bandwidth weighting + :var list unrecognized_bandwidth_entries: **\*** bandwidth weighting information that isn't yet recognized :var dict protocols: mapping of protocols to their supported versions
- :var str digest: ***** router's hex encoded digest of our corresponding + :var str digest: **\*** router's hex encoded digest of our corresponding microdescriptor (**deprecated**, use microdescriptor_digest instead) - :var str microdescriptor_digest: ***** router's base64 encoded digest of our corresponding microdescriptor + :var str microdescriptor_digest: **\*** router's base64 encoded digest of our corresponding microdescriptor
.. versionchanged:: 1.6.0 Added the protocols attribute. @@ -648,7 +648,7 @@ class RouterStatusEntryMicroV3(RouterStatusEntry): .. versionchanged:: 1.7.0 Added the microdescriptor_digest attribute to replace our now deprecated digest attribute.
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined """
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py index 88003fe0..2d9133f5 100644 --- a/stem/descriptor/server_descriptor.py +++ b/stem/descriptor/server_descriptor.py @@ -6,7 +6,7 @@ Parsing for Tor server descriptors, which contains the infrequently changing information about a Tor relay (contact information, exit policy, public keys, etc). This information is provided from a few sources...
-* The control port via 'GETINFO desc/*' queries. +* The control port via 'GETINFO desc/\*' queries.
* The 'cached-descriptors' file in Tor's data directory.
@@ -287,7 +287,7 @@ def _parse_platform_line(descriptor, entries): # version, but might as well try to save our caller the effort.
value = _value('platform', entries) - platform_match = re.match('^(?:node-)?Tor (\S*).* on (.*)$', value) + platform_match = re.match('^(?:node-)?Tor (\S*).* on (.*)$', value)
if platform_match: version_str, descriptor.operating_system = platform_match.groups() @@ -459,44 +459,44 @@ class ServerDescriptor(Descriptor): """ Common parent for server descriptors.
- :var str nickname: ***** relay's nickname + :var str nickname: **\*** relay's nickname :var str fingerprint: identity key fingerprint - :var datetime published: ***** time in UTC when this descriptor was made + :var datetime published: **\*** time in UTC when this descriptor was made
- :var str address: ***** IPv4 address of the relay - :var int or_port: ***** port used for relaying - :var int socks_port: ***** port used as client (**deprecated**, always **None**) - :var int dir_port: ***** port used for descriptor mirroring + :var str address: **\*** IPv4 address of the relay + :var int or_port: **\*** port used for relaying + :var int socks_port: **\*** port used as client (**deprecated**, always **None**) + :var int dir_port: **\*** port used for descriptor mirroring
:var bytes platform: line with operating system and tor version :var stem.version.Version tor_version: version of tor :var str operating_system: operating system :var int uptime: uptime when published in seconds :var bytes contact: contact information - :var stem.exit_policy.ExitPolicy exit_policy: ***** stated exit policy - :var stem.exit_policy.MicroExitPolicy exit_policy_v6: ***** exit policy for IPv6 - :var BridgeDistribution bridge_distribution: ***** preferred method of providing this relay's + :var stem.exit_policy.ExitPolicy exit_policy: **\*** stated exit policy + :var stem.exit_policy.MicroExitPolicy exit_policy_v6: **\*** exit policy for IPv6 + :var BridgeDistribution bridge_distribution: **\*** preferred method of providing this relay's address if a bridge - :var set family: ***** nicknames or fingerprints of declared family + :var set family: **\*** nicknames or fingerprints of declared family
- :var int average_bandwidth: ***** average rate it's willing to relay in bytes/s - :var int burst_bandwidth: ***** burst rate it's willing to relay in bytes/s - :var int observed_bandwidth: ***** estimated capacity based on usage in bytes/s + :var int average_bandwidth: **\*** average rate it's willing to relay in bytes/s + :var int burst_bandwidth: **\*** burst rate it's willing to relay in bytes/s + :var int observed_bandwidth: **\*** estimated capacity based on usage in bytes/s
:var list link_protocols: link protocols supported by the relay :var list circuit_protocols: circuit protocols supported by the relay - :var bool is_hidden_service_dir: ***** indicates if the relay serves hidden + :var bool is_hidden_service_dir: **\*** indicates if the relay serves hidden service descriptors - :var bool hibernating: ***** hibernating when published - :var bool allow_single_hop_exits: ***** flag if single hop exiting is allowed - :var bool allow_tunneled_dir_requests: ***** flag if tunneled directory + :var bool hibernating: **\*** hibernating when published + :var bool allow_single_hop_exits: **\*** flag if single hop exiting is allowed + :var bool allow_tunneled_dir_requests: **\*** flag if tunneled directory requests are accepted - :var bool extra_info_cache: ***** flag if a mirror for extra-info documents + :var bool extra_info_cache: **\*** flag if a mirror for extra-info documents :var str extra_info_digest: upper-case hex encoded digest of our extra-info document :var str extra_info_sha256_digest: base64 encoded sha256 digest of our extra-info document :var bool eventdns: flag for evdns backend (**deprecated**, always unset) :var str ntor_onion_key: base64 key used to encrypt EXTEND in the ntor protocol - :var list or_addresses: ***** alternative for our address/or_port + :var list or_addresses: **\*** alternative for our address/or_port attributes, each entry is a tuple of the form (address (**str**), port (**int**), is_ipv6 (**bool**)) :var dict protocols: mapping of protocols to their supported versions @@ -511,7 +511,7 @@ class ServerDescriptor(Descriptor): :var int write_history_interval: seconds per interval :var list write_history_values: bytes written during each interval
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined
.. versionchanged:: 1.5.0 @@ -785,14 +785,14 @@ class RelayDescriptor(ServerDescriptor): :var str ed25519_master_key: base64 encoded master key for our ed25519 certificate :var str ed25519_signature: signature of this document using ed25519
- :var str onion_key: ***** key used to encrypt EXTEND cells + :var str onion_key: **\*** key used to encrypt EXTEND cells :var str onion_key_crosscert: signature generated using the onion_key :var str ntor_onion_key_crosscert: signature generated using the ntor-onion-key :var str ntor_onion_key_crosscert_sign: sign of the corresponding ed25519 public key - :var str signing_key: ***** relay's long-term identity key - :var str signature: ***** signature for this descriptor + :var str signing_key: **\*** relay's long-term identity key + :var str signature: **\*** signature for this descriptor
- ***** attribute is required when we're parsed with validation + **\*** attribute is required when we're parsed with validation
.. versionchanged:: 1.5.0 Added the ed25519_certificate, ed25519_master_key, ed25519_signature, diff --git a/stem/descriptor/tordnsel.py b/stem/descriptor/tordnsel.py index a40467b4..8a651864 100644 --- a/stem/descriptor/tordnsel.py +++ b/stem/descriptor/tordnsel.py @@ -51,12 +51,12 @@ class TorDNSEL(Descriptor): TorDNSEL descriptor (`exitlist specification https://www.torproject.org/tordnsel/exitlist-spec.txt`_)
- :var str fingerprint: ***** authority's fingerprint - :var datetime published: ***** time in UTC when this descriptor was made - :var datetime last_status: ***** time in UTC when the relay was seen in a v2 network status - :var list exit_addresses: ***** list of (str address, datetime date) tuples consisting of the found IPv4 exit address and the time + :var str fingerprint: **\*** authority's fingerprint + :var datetime published: **\*** time in UTC when this descriptor was made + :var datetime last_status: **\*** time in UTC when the relay was seen in a v2 network status + :var list exit_addresses: **\*** list of (str address, datetime date) tuples consisting of the found IPv4 exit address and the time
- ***** attribute is either required when we're parsed with validation or has + **\*** attribute is either required when we're parsed with validation or has a default value, others are left as **None** if undefined """
diff --git a/stem/directory.py b/stem/directory.py index 7239f9a0..01eca70b 100644 --- a/stem/directory.py +++ b/stem/directory.py @@ -62,18 +62,18 @@ GITWEB_AUTHORITY_URL = 'https://gitweb.torproject.org/tor.git/plain/src/app/conf GITWEB_FALLBACK_URL = 'https://gitweb.torproject.org/tor.git/plain/src/app/config/fallback_dirs.inc' FALLBACK_CACHE_PATH = os.path.join(os.path.dirname(__file__), 'cached_fallbacks.cfg')
-AUTHORITY_NAME = re.compile('"(\S+) orport=(\d+) .*"') -AUTHORITY_V3IDENT = re.compile('"v3ident=([\dA-F]{40}) "') -AUTHORITY_IPV6 = re.compile('"ipv6=[([\da-f:]+)]:(\d+) "') -AUTHORITY_ADDR = re.compile('"([\d.]+):(\d+) ([\dA-F ]{49})",') +AUTHORITY_NAME = re.compile('"(\S+) orport=(\d+) .*"') +AUTHORITY_V3IDENT = re.compile('"v3ident=([\dA-F]{40}) "') +AUTHORITY_IPV6 = re.compile('"ipv6=\[([\da-f:]+)\]:(\d+) "') +AUTHORITY_ADDR = re.compile('"([\d\.]+):(\d+) ([\dA-F ]{49})",')
FALLBACK_DIV = '/* ===== */' -FALLBACK_MAPPING = re.compile('/*\s+(\S+)=(\S*)\s+*/') +FALLBACK_MAPPING = re.compile('/\*\s+(\S+)=(\S*)\s+\*/')
-FALLBACK_ADDR = re.compile('"([\d.]+):(\d+) orport=(\d+) id=([\dA-F]{40}).*') -FALLBACK_NICKNAME = re.compile('/* nickname=(\S+) */') -FALLBACK_EXTRAINFO = re.compile('/* extrainfo=([0-1]) */') -FALLBACK_IPV6 = re.compile('" ipv6=[([\da-f:]+)]:(\d+)"') +FALLBACK_ADDR = re.compile('"([\d\.]+):(\d+) orport=(\d+) id=([\dA-F]{40}).*') +FALLBACK_NICKNAME = re.compile('/\* nickname=(\S+) \*/') +FALLBACK_EXTRAINFO = re.compile('/\* extrainfo=([0-1]) \*/') +FALLBACK_IPV6 = re.compile('" ipv6=\[([\da-f:]+)\]:(\d+)"')
def _match_with(lines, regexes, required = None): diff --git a/stem/exit_policy.py b/stem/exit_policy.py index 5bdadf9b..76d75e55 100644 --- a/stem/exit_policy.py +++ b/stem/exit_policy.py @@ -139,7 +139,7 @@ def get_config_policy(rules, ip_address = None): if not rule: continue
- if not re.search(':[\d-*]+$', rule): + if not re.search(':[\d\-\*]+$', rule): rule = '%s:*' % rule
if 'private' in rule: @@ -642,7 +642,7 @@ class ExitPolicyRule(object): This should be treated as an immutable object.
.. versionchanged:: 1.5.0 - Support for 'accept6/reject6' entries and '*4/6' wildcards. + Support for 'accept6/reject6' entries and '\*4/6' wildcards.
:var bool is_accept: indicates if exiting is allowed or disallowed
@@ -714,7 +714,7 @@ class ExitPolicyRule(object): """ **True** if we'll match against **any** address, **False** otherwise.
- Note that this is different than *4, *6, or '/0' address which are + Note that this is different than \*4, \*6, or '/0' address which are wildcards for only either IPv4 or IPv6.
:returns: **bool** for if our address matching is a wildcard diff --git a/stem/process.py b/stem/process.py index 522ee7bf..80824bdc 100644 --- a/stem/process.py +++ b/stem/process.py @@ -139,7 +139,7 @@ def launch_tor(tor_cmd = 'tor', args = None, torrc_path = None, completion_perce signal.setitimer(signal.ITIMER_REAL, timeout)
bootstrap_line = re.compile('Bootstrapped ([0-9]+)%') - problem_line = re.compile('[(warn|err)] (.*)$') + problem_line = re.compile('\[(warn|err)\] (.*)$') last_problem = 'Timed out'
while True: diff --git a/stem/response/__init__.py b/stem/response/__init__.py index ea4d2331..7d2c5c5c 100644 --- a/stem/response/__init__.py +++ b/stem/response/__init__.py @@ -50,7 +50,7 @@ __all__ = [ 'SingleLineResponse', ]
-KEY_ARG = re.compile('^(\S+)=') +KEY_ARG = re.compile('^(\S+)=')
def convert(response_type, message, **kwargs): diff --git a/stem/response/events.py b/stem/response/events.py index da0b3f9d..a9f563c6 100644 --- a/stem/response/events.py +++ b/stem/response/events.py @@ -19,7 +19,7 @@ from stem.util import connection, log, str_tools, tor_tools # because some positional arguments, like circuit paths, can have an equal # sign.
-KW_ARG = re.compile('^(.*) ([A-Za-z0-9_]+)=(\S*)$') +KW_ARG = re.compile('^(.*) ([A-Za-z0-9_]+)=(\S*)$') QUOTED_KW_ARG = re.compile('^(.*) ([A-Za-z0-9_]+)="(.*)"$') CELL_TYPE = re.compile('^[a-z0-9_]+$') PARSE_NEWCONSENSUS_EVENTS = True diff --git a/stem/util/connection.py b/stem/util/connection.py index d9a23815..2ddecd74 100644 --- a/stem/util/connection.py +++ b/stem/util/connection.py @@ -47,7 +47,7 @@ Connection and networking based utility functions. **NETSTAT_WINDOWS** netstat command under Windows **SS** ss command **LSOF** lsof command - **SOCKSTAT** sockstat command under *nix + **SOCKSTAT** sockstat command under \*nix **BSD_SOCKSTAT** sockstat command under FreeBSD **BSD_PROCSTAT** procstat command under FreeBSD **BSD_FSTAT** fstat command under OpenBSD @@ -125,28 +125,28 @@ RESOLVER_FILTER = { Resolver.PROC: '',
# tcp 0 586 192.168.0.1:44284 38.229.79.2:443 ESTABLISHED 15843/tor - Resolver.NETSTAT: '^{protocol}\s+.*\s+{local}\s+{remote}\s+ESTABLISHED\s+{pid}/{name}\s*$', + Resolver.NETSTAT: '^{protocol}\s+.*\s+{local}\s+{remote}\s+ESTABLISHED\s+{pid}/{name}\s*$',
# tcp 586 192.168.0.1:44284 38.229.79.2:443 ESTABLISHED 15843 - Resolver.NETSTAT_WINDOWS: '^\s*{protocol}\s+{local}\s+{remote}\s+ESTABLISHED\s+{pid}\s*$', + Resolver.NETSTAT_WINDOWS: '^\s*{protocol}\s+{local}\s+{remote}\s+ESTABLISHED\s+{pid}\s*$',
# tcp ESTAB 0 0 192.168.0.20:44415 38.229.79.2:443 users:(("tor",15843,9)) - Resolver.SS: '^{protocol}\s+ESTAB\s+.*\s+{local}\s+{remote}\s+users:(("{name}",(?:pid=)?{pid},(?:fd=)?[0-9]+))$', + Resolver.SS: '^{protocol}\s+ESTAB\s+.*\s+{local}\s+{remote}\s+users:\(\("{name}",(?:pid=)?{pid},(?:fd=)?[0-9]+\)\)$',
# tor 3873 atagar 45u IPv4 40994 0t0 TCP 10.243.55.20:45724->194.154.227.109:9001 (ESTABLISHED) - Resolver.LSOF: '^{name}\s+{pid}\s+.*\s+{protocol}\s+{local}->{remote} (ESTABLISHED)$', + Resolver.LSOF: '^{name}\s+{pid}\s+.*\s+{protocol}\s+{local}->{remote} \(ESTABLISHED\)$',
# atagar tor 15843 tcp4 192.168.0.20:44092 68.169.35.102:443 ESTABLISHED - Resolver.SOCKSTAT: '^\S+\s+{name}\s+{pid}\s+{protocol}4\s+{local}\s+{remote}\s+ESTABLISHED$', + Resolver.SOCKSTAT: '^\S+\s+{name}\s+{pid}\s+{protocol}4\s+{local}\s+{remote}\s+ESTABLISHED$',
# _tor tor 4397 12 tcp4 172.27.72.202:54011 127.0.0.1:9001 - Resolver.BSD_SOCKSTAT: '^\S+\s+{name}\s+{pid}\s+\S+\s+{protocol}4\s+{local}\s+{remote}$', + Resolver.BSD_SOCKSTAT: '^\S+\s+{name}\s+{pid}\s+\S+\s+{protocol}4\s+{local}\s+{remote}$',
# 3561 tor 4 s - rw---n-- 2 0 TCP 10.0.0.2:9050 10.0.0.1:22370 - Resolver.BSD_PROCSTAT: '^\s*{pid}\s+{name}\s+.*\s+{protocol}\s+{local}\s+{remote}$', + Resolver.BSD_PROCSTAT: '^\s*{pid}\s+{name}\s+.*\s+{protocol}\s+{local}\s+{remote}$',
# _tor tor 15843 20* internet stream tcp 0x0 192.168.1.100:36174 --> 4.3.2.1:443 - Resolver.BSD_FSTAT: '^\S+\s+{name}\s+{pid}\s+.*\s+{protocol}\s+\S+\s+{local}\s+[-<]-[->]\s+{remote}$', + Resolver.BSD_FSTAT: '^\S+\s+{name}\s+{pid}\s+.*\s+{protocol}\s+\S+\s+{local}\s+[-<]-[->]\s+{remote}$', }
@@ -243,11 +243,11 @@ def get_connections(resolver = None, process_pid = None, process_name = None): raise IOError("Unable to query '%s': %s" % (resolver_command, exc))
resolver_regex_str = RESOLVER_FILTER[resolver].format( - protocol = '(?P<protocol>\S+)', - local = '(?P<local>[[]0-9a-f.:]+)', - remote = '(?P<remote>[[]0-9a-f.:]+)', + protocol = '(?P<protocol>\S+)', + local = '(?P<local>[\[\]0-9a-f.:]+)', + remote = '(?P<remote>[\[\]0-9a-f.:]+)', pid = process_pid if process_pid else '[0-9]*', - name = process_name if process_name else '\S*', + name = process_name if process_name else '\S*', )
_log('Resolver regex: %s' % resolver_regex_str) diff --git a/stem/util/system.py b/stem/util/system.py index 80e80f75..c04eb673 100644 --- a/stem/util/system.py +++ b/stem/util/system.py @@ -706,7 +706,7 @@ def pid_by_name(process_name, multiple = False): results = stem.util.system.call('tasklist', None)
if results: - tasklist_regex = re.compile('^\s*%s\s+(?P<pid>[0-9]*)' % process_name) + tasklist_regex = re.compile('^\s*%s\s+(?P<pid>[0-9]*)' % process_name)
for line in results: match = tasklist_regex.search(line) diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py index 4455c284..03741d98 100644 --- a/stem/util/test_tools.py +++ b/stem/util/test_tools.py @@ -323,7 +323,7 @@ def test_runtimes():
def clean_orphaned_pyc(paths): """ - Deletes any file with a *.pyc extention without a corresponding *.py. This + Deletes any file with a \*.pyc extention without a corresponding \*.py. This helps to address a common gotcha when deleting python files...
* You delete module 'foo.py' and run the tests to ensure that you haven't diff --git a/test/output.py b/test/output.py index 0eedfa27..9df1bc93 100644 --- a/test/output.py +++ b/test/output.py @@ -169,7 +169,7 @@ def strip_module(line_type, line_content): repetitive, and redundant with the headers. """
- m = re.match('.*( (test..*?)).*', line_content) + m = re.match('.*( \(test\..*?\)).*', line_content)
if m: line_content = line_content.replace(m.groups()[0], '', 1) @@ -182,7 +182,7 @@ def runtimes(line_type, line_content): Provides test runtimes if showing verbose results. """
- m = re.search('(test.[^)]*)', line_content) + m = re.search('(test\.[^)]*)', line_content)
if m and line_type == LineType.OK: test = '%s.%s' % (m.group(0), line_content.split()[0]) @@ -283,7 +283,7 @@ class ErrorTracker(object): else: self._errors.append(line_content)
- module_match = re.match('.*((test.\S+).\S+).*', line_content) + module_match = re.match('.*\((test\.\S+)\.\S+\).*', line_content)
if module_match: self._error_modules.add(module_match.group(1)) diff --git a/test/task.py b/test/task.py index 832b397f..a7dc15a6 100644 --- a/test/task.py +++ b/test/task.py @@ -175,7 +175,7 @@ def _check_for_unused_tests(paths): with open(py_path) as f: file_contents = f.read()
- test_match = re.search('^class (\S*)(unittest.TestCase):$', file_contents, re.MULTILINE) + test_match = re.search('^class (\S*)\(unittest.TestCase\):$', file_contents, re.MULTILINE)
if test_match: class_name = test_match.groups()[0] diff --git a/test/unit/directory/fallback.py b/test/unit/directory/fallback.py index 59d59567..3f5ceca3 100644 --- a/test/unit/directory/fallback.py +++ b/test/unit/directory/fallback.py @@ -131,7 +131,7 @@ class TestFallback(unittest.TestCase):
@patch(URL_OPEN, Mock(return_value = io.BytesIO(FALLBACK_GITWEB_CONTENT.replace(b'version=2.0.0', b'version')))) def test_from_remote_malformed_header(self): - self.assertRaisesRegexp(IOError, 'Malformed fallback directory header line: /* version */', stem.directory.Fallback.from_remote) + self.assertRaisesRegexp(IOError, 'Malformed fallback directory header line: /\* version \*/', stem.directory.Fallback.from_remote)
def test_from_remote_malformed(self): test_values = { diff --git a/test/unit/installation.py b/test/unit/installation.py index feb52d89..fd8709ba 100644 --- a/test/unit/installation.py +++ b/test/unit/installation.py @@ -31,7 +31,7 @@ class TestInstallation(unittest.TestCase): # # packages = ['stem', 'stem.descriptor', 'stem.util'],
- modules = json.loads(re.search('packages = ([.*])', self.setup_contents).group(1).replace("'", '"')) + modules = json.loads(re.search('packages = (\[.*\])', self.setup_contents).group(1).replace("'", '"')) module_paths = dict([(m, os.path.join(test.STEM_BASE, m.replace('.', os.path.sep))) for m in modules])
for module, path in module_paths.items():
tor-commits@lists.torproject.org