text
stringlengths
81
112k
Packages msg according to Scratch message specification (encodes and appends length prefix to msg). Credit to chalkmarrow from the scratch.mit.edu forums for the prefix encoding code. def _pack(self, msg): """ Packages msg according to Scratch message specification (encodes and ...
Converts a string from Scratch to its proper type in Python. Expects a string with its delimiting quotes in place. Returns either a string, int or float. def _get_type(self, s): """ Converts a string from Scratch to its proper type in Python. Expects a string with its delimitin...
Escapes double quotes by adding another double quote as per the Scratch protocol. Expects a string without its delimiting quotes. Returns a new escaped string. def _escape(self, msg): """ Escapes double quotes by adding another double quote as per the Scratch protocol. Expects a...
Removes double quotes that were used to escape double quotes. Expects a string without its delimiting quotes, or a number. Returns a new unescaped string. def _unescape(self, msg): """ Removes double quotes that were used to escape double quotes. Expects a string without its del...
Returns True if message is a proper Scratch message, else return False. def _is_msg(self, msg): """ Returns True if message is a proper Scratch message, else return False. """ if not msg or len(msg) < self.prefix_len: return False length = self._extract_len(msg[:self...
Given a broacast message, returns the message that was broadcast. def _parse_broadcast(self, msg): """ Given a broacast message, returns the message that was broadcast. """ # get message, remove surrounding quotes, and unescape return self._unescape(self._get_type(msg[self.broad...
Given a sensor-update message, returns the sensors/variables that were updated as a dict that maps sensors/variables to their updated values. def _parse_sensorupdate(self, msg): """ Given a sensor-update message, returns the sensors/variables that were updated as a dict that maps sensor...
Parses a Scratch message and returns a tuple with the first element as the message type, and the second element as the message payload. The payload for a 'broadcast' message is a string, and the payload for a 'sensor-update' message is a dict whose keys are variables, and values are up...
Writes string data out to Scratch def _write(self, data): """ Writes string data out to Scratch """ total_sent = 0 length = len(data) while total_sent < length: try: sent = self.socket.send(data[total_sent:]) except socket.error as...
Reads size number of bytes from Scratch and returns data as a string def _read(self, size): """ Reads size number of bytes from Scratch and returns data as a string """ data = '' while len(data) < size: try: chunk = self.socket.recv(size-len(data)) ...
Receives and returns a message from Scratch def _recv(self): """ Receives and returns a message from Scratch """ prefix = self._read(self.prefix_len) msg = self._read(self._extract_len(prefix)) return prefix + msg
Connects to Scratch. def connect(self): """ Connects to Scratch. """ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.socket.connect((self.host, self.port)) except socket.error as (err, msg): self.connected = False ...
Closes connection to Scratch def disconnect(self): """ Closes connection to Scratch """ try: # connection may already be disconnected, so catch exceptions self.socket.shutdown(socket.SHUT_RDWR) # a proper disconnect except socket.error: pass self....
Given a dict of sensors and values, updates those sensors with the values in Scratch. def sensorupdate(self, data): """ Given a dict of sensors and values, updates those sensors with the values in Scratch. """ if not isinstance(data, dict): raise TypeError(...
Broadcasts msg to Scratch. msg can be a single message or an iterable (list, tuple, set, generator, etc.) of messages. def broadcast(self, msg): """ Broadcasts msg to Scratch. msg can be a single message or an iterable (list, tuple, set, generator, etc.) of messages. """ ...
Tests a simple topology. "Simple" means there it has no branches or cycles. "emitters" is a list of emitters, starting with a spout followed by 0 or more bolts that run in a chain. def run_simple_topology(cls, config, emitters, result_type=NAMEDTUPLE, max_spout_emits=None): """Tests a simple to...
Writes the topology to a stream or file. def write(self, stream): """Writes the topology to a stream or file.""" topology = self.createTopology() def write_it(stream): transportOut = TMemoryBuffer() protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut) ...
Reads the topology from a stream or file. def read(self, stream): """Reads the topology from a stream or file.""" def read_it(stream): bytes = stream.read() transportIn = TMemoryBuffer(bytes) protocolIn = TBinaryProtocol.TBinaryProtocol(transportIn) topol...
Build a StormTopology .jar which encapsulates the topology defined in topology_dir. Optionally override the module and function names. This feature supports the definition of multiple topologies in a single directory. def build_jar(source_jar_path, dest_jar_path, config, venv=None, definition=None, logdir=...
This function is kind of a hack, but useful when a Python task encounters a fatal exception. "msg" should be a simple string like "E_SPOUTFAILED". This function sends "msg" as-is to the Storm worker, which tries to parse it as JSON. The hacky aspect is that we *deliberately* make it fail by sending it n...
A more efficient way to emit a number of tuples at once. def emitMany(*args, **kwargs): """A more efficient way to emit a number of tuples at once.""" global MODE if MODE == Bolt: emitManyBolt(*args, **kwargs) elif MODE == Spout: emitManySpout(*args, **kwargs)
Handler to allow process to be remotely debugged. def remote_debug(sig,frame): """Handler to allow process to be remotely debugged.""" def _raiseEx(ex): """Raise specified exception in the remote process""" _raiseEx.ex = ex _raiseEx.ex = None try: # Provide some useful func...
Interrupt a running process and debug it. def debug_process(pid): """Interrupt a running process and debug it.""" os.kill(pid, signal.SIGUSR1) # Signal process. pipe = NamedPipe(pipename(pid), 1) try: while pipe.is_open(): txt=raw_input(pipe.get()) + '\n' pipe.put(txt) ...
UTF8 encodes all of the NVP values. def _encode_utf8(self, **kwargs): """ UTF8 encodes all of the NVP values. """ if is_py3: # This is only valid for Python 2. In Python 3, unicode is # everywhere (yay). return kwargs unencoded_pairs = kwargs...
Checks kwargs for the values specified in 'requires', which is a tuple of strings. These strings are the NVP names of the required values. def _check_required(self, requires, **kwargs): """ Checks kwargs for the values specified in 'requires', which is a tuple of strings. These strings ...
Wrapper method for executing all API commands over HTTP. This method is further used to implement wrapper methods listed here: https://www.x.com/docs/DOC-1374 ``method`` must be a supported NVP method listed at the above address. ``kwargs`` the actual call parameters def _call(self, m...
Returns the prepared call parameters. Mind, these will be keyword arguments to ``requests.post``. ``method`` the NVP method ``kwargs`` the actual call parameters def _get_call_params(self, method, **kwargs): """ Returns the prepared call parameters. Mind, these will be keyword ...
Shortcut for the AddressVerify method. ``email``:: Email address of a PayPal member to verify. Maximum string length: 255 single-byte characters Input mask: ?@?.?? ``street``:: First line of the billing or shipping postal address to verify. T...
Shortcut for the DoAuthorization method. Use the TRANSACTIONID from DoExpressCheckoutPayment for the ``transactionid``. The latest version of the API does not support the creation of an Order from `DoDirectPayment`. The `amt` should be the same as passed to `DoExpressCheckoutPayment`. ...
Shortcut for the DoCapture method. Use the TRANSACTIONID from DoAuthorization, DoDirectPayment or DoExpressCheckoutPayment for the ``authorizationid``. The `amt` should be the same as the authorized transaction. def do_capture(self, authorizationid, amt, completetype='Complete', ...
Shortcut for the DoDirectPayment method. ``paymentaction`` could be 'Authorization' or 'Sale' To issue a Sale immediately:: charge = { 'amt': '10.00', 'creditcardtype': 'Visa', 'acct': '4812177017895760', 'expdate': '012010',...
Shortcut for the TransactionSearch method. Returns a PayPalResponseList object, which merges the L_ syntax list to a list of dictionaries with properly named keys. Note that the API will limit returned transactions to 100. Required Kwargs --------------- * STARTDATE ...
Shortcut for RefundTransaction method. Note new API supports passing a PayerID instead of a transaction id, exactly one must be provided. Optional: INVOICEID REFUNDTYPE AMT CURRENCYCODE NOTE RETRY...
Returns the URL to redirect the user to for the Express checkout. Express Checkouts must be verified by the customer by redirecting them to the PayPal website. Use the token returned in the response from :meth:`set_express_checkout` with this function to figure out where to redirect the...
ERROR: type should be string, got "https://www.sandbox.paypal.com/webscr\n ?cmd=_cart\n &upload=1\n\ndef generate_cart_upload_redirect_url(self, **kwargs):\n \"\"\"https://www.sandbox.paypal.com/webscr\n ?cmd=_cart\n &upload=1\n \"\"\"\n required_vals = ('business', 'item_name_1', 'amount_1', 'quantity_1')\n self._check_required(required_vals, **kwargs)\n url = \"%s?cmd=_cart&upload=1\" % self.config.PAYPAL_URL_BASE\n additional = self._encode_utf8(**kwargs)\n additional = urlencode(additional)\n return url + \"&\" + additional"
Shortcut for the GetRecurringPaymentsProfile method. This returns details for a recurring payment plan. The ``profileid`` is a value included in the response retrieved by the function ``create_recurring_payments_profile``. The profile details include the data provided when the profile w...
Shortcut to the ManageRecurringPaymentsProfileStatus method. ``profileid`` is the same profile id used for getting profile details. ``action`` should be either 'Cancel', 'Suspend', or 'Reactivate'. ``note`` is optional and is visible to the user. It contains the reason for the chang...
Shortcut to the UpdateRecurringPaymentsProfile method. ``profileid`` is the same profile id used for getting profile details. The keyed arguments are data in the payment profile which you wish to change. The profileid does not change. Anything else will take the new value. Most of, tho...
Shortcut to the BMCreateButton method. See the docs for details on arguments: https://cms.paypal.com/mx/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_BMCreateButton The L_BUTTONVARn fields are especially important, so make sure to read those and act accordingly. See...
Checks for the presence of errors in the response. Returns ``True`` if all is well, ``False`` otherwise. :rtype: bool :returns ``True`` if PayPal says our query was successful. def success(self): """ Checks for the presence of errors in the response. Returns ``True`` if ...
Given a country code abbreviation, check to see if it matches the country table. abbrev: (str) Country code to evaluate. case_sensitive: (bool) When True, enforce case sensitivity. Returns True if valid, False if not. def is_valid_country_abbrev(abbrev, case_sensitive=False): """ Given a coun...
Given a country code abbreviation, get the full name from the table. abbrev: (str) Country code to retrieve the full name of. case_sensitive: (bool) When True, enforce case sensitivity. def get_name_from_abbrev(abbrev, case_sensitive=False): """ Given a country code abbreviation, get the full name fro...
Updates declared fields with fields converted from the Mongoengine model passed as the `model` class Meta option. def get_declared_fields(mcs, klass, *args, **kwargs): """Updates declared fields with fields converted from the Mongoengine model passed as the `model` class Meta option. ""...
Helper function to update an already existing document instead of creating a new one. :param obj: Mongoengine Document to update :param data: incomming payload to deserialize :return: an :class UnmarshallResult: Example: :: from marshmallow_mongoengine import ModelSchema from mymod...
Bind a marshmallow field to it corresponding mongoengine field :param mongo_field_cls: Mongoengine Field :param marshmallow_field_cls: Marshmallow Field :param available_params: List of :class marshmallow_mongoengine.cnoversion.params.MetaParam: instances to import the mongoengine field config to ma...
:return: The Marshmallow Field instanciated and configured def build_marshmallow_field(self, **kwargs): """ :return: The Marshmallow Field instanciated and configured """ field_kwargs = None for param in self.params: field_kwargs = param.apply(field_kwargs) f...
Main loop. def loop(self, timeout = 1): """Main loop.""" rlist = [self.sock] wlist = [] if len(self.out_packet) > 0: wlist.append(self.sock) to_read, to_write, _ = select.select(rlist, wlist, [], timeout) if len(to_read) > 0: ret, _ = se...
Misc loop. def loop_misc(self): """Misc loop.""" self.check_keepalive() if self.last_retry_check + 1 < time.time(): pass return NC.ERR_SUCCESS
Send keepalive/PING if necessary. def check_keepalive(self): """Send keepalive/PING if necessary.""" if self.sock != NC.INVALID_SOCKET and time.time() - self.last_msg_out >= self.keep_alive: if self.state == NC.CS_CONNECTED: self.send_pingreq() else: ...
Incoming packet handler dispatcher. def packet_handle(self): """Incoming packet handler dispatcher.""" cmd = self.in_packet.command & 0xF0 if cmd == NC.CMD_CONNACK: return self.handle_connack() elif cmd == NC.CMD_PINGRESP: return self.handle_pingresp() ...
Connect to server. def connect(self, version = 3, clean_session = 1, will = None): """Connect to server.""" self.clean_session = clean_session self.will = None if will is not None: self.will = NyamukMsg( topic = will['topic'], ...
Disconnect from server. def disconnect(self): """Disconnect from server.""" self.logger.info("DISCONNECT") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.state = NC.CS_DISCONNECTING ret = self.send_disconnect() ret2, bytes_written = se...
Subscribe to some topic. def subscribe(self, topic, qos): """Subscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", topic) return self.send_subscribe(False, [(utf8encode(topic), qos)])
Subscribe to some topics. def subscribe_multi(self, topics): """Subscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", ', '.join([t for (t,q) in topics])) return self.send_subscribe(False, [(utf8encode...
Unsubscribe to some topic. def unsubscribe(self, topic): """Unsubscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", topic) return self.send_unsubscribe(False, [utf8encode(topic)])
Unsubscribe to some topics. def unsubscribe_multi(self, topics): """Unsubscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", ', '.join(topics)) return self.send_unsubscribe(False, [utf8encode(topic) ...
Send subscribe COMMAND to server. def send_subscribe(self, dup, topics): """Send subscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic)+1 for (topic, qos) in topics]) pkt.command = NC.CMD_SUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = p...
Send unsubscribe COMMAND to server. def send_unsubscribe(self, dup, topics): """Send unsubscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic) for topic in topics]) pkt.command = NC.CMD_UNSUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = pk...
Publish some payload to server. def publish(self, topic, payload = None, qos = 0, retain = False): """Publish some payload to server.""" #print "PUBLISHING (",topic,"): ", payload payloadlen = len(payload) if topic is None or qos < 0 or qos > 2: print "PUBLISH:err inval" ...
Handle incoming CONNACK command. def handle_connack(self): """Handle incoming CONNACK command.""" self.logger.info("CONNACK reveived") ret, flags = self.in_packet.read_byte() if ret != NC.ERR_SUCCESS: self.logger.error("error read byte") return ret ...
Handle incoming PINGRESP packet. def handle_pingresp(self): """Handle incoming PINGRESP packet.""" self.logger.debug("PINGRESP received") self.push_event(event.EventPingResp()) return NC.ERR_SUCCESS
Handle incoming SUBACK packet. def handle_suback(self): """Handle incoming SUBACK packet.""" self.logger.info("SUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret qos_count = self.in_packet.remaini...
Handle incoming UNSUBACK packet. def handle_unsuback(self): """Handle incoming UNSUBACK packet.""" self.logger.info("UNSUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventUnsuback(mid) self.push_e...
Handle incoming PUBLISH packet. def handle_publish(self): """Handle incoming PUBLISH packet.""" self.logger.debug("PUBLISH received") header = self.in_packet.command message = NyamukMsgAll() message.direction = NC.DIRECTION_IN message.dup = (header & 0x...
Send PUBLISH. def send_publish(self, mid, topic, payload, qos, retain, dup): """Send PUBLISH.""" self.logger.debug("Send PUBLISH") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN #NOTE: payload may be any kind of data # yet if it is a unicode string we...
Handle incoming PUBACK packet. def handle_puback(self): """Handle incoming PUBACK packet.""" self.logger.info("PUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPuback(mid) self.push_event(evt) ...
Handle incoming PUBREC packet. def handle_pubrec(self): """Handle incoming PUBREC packet.""" self.logger.info("PUBREC received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrec(mid) self.push_event(evt) ...
Handle incoming PUBREL packet. def handle_pubrel(self): """Handle incoming PUBREL packet.""" self.logger.info("PUBREL received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrel(mid) self.push_event(evt) ...
Handle incoming PUBCOMP packet. def handle_pubcomp(self): """Handle incoming PUBCOMP packet.""" self.logger.info("PUBCOMP received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubcomp(mid) self.push_event(...
Send PUBREC response to server. def pubrec(self, mid): """Send PUBREC response to server.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("Send PUBREC (msgid=%s)", mid) pkt = MqttPkt() pkt.command = NC.CMD_PUBREC pkt.remaining_l...
Connect to some addr. def connect(sock, addr): """Connect to some addr.""" try: sock.connect(addr) except ssl.SSLError as e: return (ssl.SSLError, e.strerror if e.strerror else e.message) except socket.herror as (_, msg): return (socket.herror, msg) except socket.gaierror as...
Read from socket and return it's byte array representation. count = number of bytes to read def read(sock, count): """Read from socket and return it's byte array representation. count = number of bytes to read """ data = None try: data = sock.recv(count) except ssl.SSLError as e: ...
Write payload to socket. def write(sock, payload): """Write payload to socket.""" try: length = sock.send(payload) except ssl.SSLError as e: return -1, (ssl.SSLError, e.strerror if strerror else e.message) except socket.herror as (_, msg): return -1, (socket.error, msg) exce...
Print packet content. def dump(self): """Print packet content.""" print "-----MqttPkt------" print "command = ", self.command print "have_remaining = ", self.have_remaining print "remaining_count = ", self.remaining_count print "mid = ", self.mid print "remaining...
from _mosquitto_packet_alloc. def alloc(self): """from _mosquitto_packet_alloc.""" byte = 0 remaining_bytes = bytearray(5) i = 0 remaining_length = self.remaining_length self.payload = None self.remaining_count = 0 loop_flag = True ...
Build packet for CONNECT command. def connect_build(self, nyamuk, keepalive, clean_session, retain = 0, dup = 0, version = 3): """Build packet for CONNECT command.""" will = 0; will_topic = None byte = 0 client_id = utf8encode(nyamuk.client_id) username = utf8encode(nyamuk.use...
Write a string to this packet. def write_string(self, string): """Write a string to this packet.""" self.write_uint16(len(string)) self.write_bytes(string, len(string))
Write 2 bytes. def write_uint16(self, word): """Write 2 bytes.""" self.write_byte(nyamuk_net.MOSQ_MSB(word)) self.write_byte(nyamuk_net.MOSQ_LSB(word))
Write one byte. def write_byte(self, byte): """Write one byte.""" self.payload[self.pos] = byte self.pos = self.pos + 1
Write n number of bytes to this packet. def write_bytes(self, data, n): """Write n number of bytes to this packet.""" for pos in xrange(0, n): self.payload[self.pos + pos] = data[pos] self.pos += n
Read a byte. def read_byte(self): """Read a byte.""" if self.pos + 1 > self.remaining_length: return NC.ERR_PROTOCOL, None byte = self.payload[self.pos] self.pos += 1 return NC.ERR_SUCCESS, byte
Read 2 bytes. def read_uint16(self): """Read 2 bytes.""" if self.pos + 2 > self.remaining_length: return NC.ERR_PROTOCOL msb = self.payload[self.pos] self.pos += 1 lsb = self.payload[self.pos] self.pos += 1 word = (msb << 8) + lsb ...
Read count number of bytes. def read_bytes(self, count): """Read count number of bytes.""" if self.pos + count > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(count) for x in xrange(0, count): ba[x] = self.payload[self.pos] ...
Read string. def read_string(self): """Read string.""" rc, length = self.read_uint16() if rc != NC.ERR_SUCCESS: return rc, None if self.pos + length > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(length) ...
Pop an event from event_list. def pop_event(self): """Pop an event from event_list.""" if len(self.event_list) > 0: evt = self.event_list.pop(0) return evt return None
Generate mid. TODO : check. def mid_generate(self): """Generate mid. TODO : check.""" self.last_mid += 1 if self.last_mid == 0: self.last_mid += 1 return self.last_mid
Enqueue packet to out_packet queue. def packet_queue(self, pkt): """Enqueue packet to out_packet queue.""" pkt.pos = 0 pkt.to_process = pkt.packet_length self.out_packet.append(pkt) return NC.ERR_SUCCESS
Write packet to network. def packet_write(self): """Write packet to network.""" bytes_written = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN, bytes_written while len(self.out_packet) > 0: pkt = self.out_packet[0] write_...
Read packet from network. def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) ...
Close our socket. def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
Build PUBLISH packet. def build_publish_pkt(self, mid, topic, payload, qos, retain, dup): """Build PUBLISH packet.""" pkt = MqttPkt() payloadlen = len(payload) packetlen = 2 + len(topic) + payloadlen if qos > 0: packetlen += 2 pkt.mid = mid ...
Send simple mqtt commands. def send_simple_command(self, cmd): """Send simple mqtt commands.""" pkt = MqttPkt() pkt.command = cmd pkt.remaining_length = 0 ret = pkt.alloc() if ret != NC.ERR_SUCCESS: return ret return self.pa...
The actual public IP of this host. def real_ip(self): """ The actual public IP of this host. """ if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
Get the current IP Tor is using. :returns str :raises TorIpError def get_current_ip(self): """ Get the current IP Tor is using. :returns str :raises TorIpError """ response = get(ICANHAZIP, proxies={"http": self.local_http_proxy}) if response.o...
Try to obtain new a usable TOR IP. :returns bool :raises TorIpError def get_new_ip(self): """ Try to obtain new a usable TOR IP. :returns bool :raises TorIpError """ attempts = 0 while True: if attempts == self.new_ip_max_attempts: ...
Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool def _ip_is_usable(self, current_ip): """ Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str ...
Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str def _manage_used_ips(self, current_ip): """ Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str """ ...
Change Tor's IP. def _obtain_new_ip(self): """ Change Tor's IP. """ with Controller.from_port( address=self.tor_address, port=self.tor_port ) as controller: controller.authenticate(password=self.tor_password) controller.signal(Signal.NEWNYM) ...
Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively. def is_local_subsection(command_dict): """Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but ...
Returns a processed request or raises an exception def _process_req_txt(req): '''Returns a processed request or raises an exception''' if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) re...