code
stringlengths
1
1.72M
language
stringclasses
1 value
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime import struct import time import sys import os relativedelta = None pa...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import itertools import datetime import calendar import thread import sys __all__ = ["...
Python
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime __all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTE...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __version__ = "1.5"
Python
""" Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ from dateutil.tz import tzfile from tarfile import TarFile import os __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __all__ = ["setca...
Python
# This code was originally contributed by Jeffrey Harris. import datetime import struct import _winreg __author__ = "Jeffrey Harris & Gustavo Niemeyer <gustavo@niemeyer.net>" __all__ = ["tzwin", "tzwinlocal"] ONEWEEK = datetime.timedelta(7) TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" TZ...
Python
#!/usr/bin/python2.5 # # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
Python
"""SocksiPy - Python SOCKS module. Version 1.00 Copyright 2006 Dan-Haim. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this ...
Python
""" iri2uri Converts an IRI to a URI. """ __author__ = "Joe Gregorio (joe@bitworking.org)" __copyright__ = "Copyright 2006, Joe Gregorio" __contributors__ = [] __version__ = "1.0.0" __license__ = "MIT" __history__ = """ """ import urlparse # Convert an IRI to a URI following the rules in RFC 3987 # # The characte...
Python
from __future__ import generators """ httplib2 A caching http interface that supports ETags and gzip to conserve bandwidth. Requires Python 2.3 or later Changelog: 2007-08-18, Rick: Modified so it's able to use a socks proxy if needed. """ __author__ = "Joe Gregorio (joe@bitworking.org)" __copyright__ = "Copyright...
Python
#!/usr/bin/env python # Copyright (c) 2007, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this l...
Python
#!/usr/bin/python2.5 # # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
Python
#!/usr/bin/python2.5 # # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
Python
#!/usr/bin/python2.5 # # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
Python
#!/usr/bin/python2.5 # # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
#---------------------------- # Name: Aaron Carson # Project: Madlibs.py # Period: 2 # Start Date: 9/17/2013 # Last Revision Date: 10/7/2013 # Version: 1.2.0 #---------------------------- swearFilter = ["dumb", "stupid", "retard", "crap", "poop", ...
Python
#!/usr/bin/python2.4 # -*- coding: UTF-8 -*- # subversion info: # $HeadURL: $ # $Author: $ # $Id: $ # $Revision: $ from distutils.core import setup import os import sys import setuptools class doc(setuptools.Command): description = 'Create the package\'s documentation' user_options = [] doc_src = "Abacum" d...
Python
import sys import simplejson """ Simple utility for loads a json file. """ if __name__ == '__main__': if len(sys.argv) < 2: print '%s: You must provide some file to load' % sys.argv[0] sys.exit(-1) fd = open(sys.argv[1]) _input = ''.join([l for l in fd.xreadlines() if l.find('#') == -1]) print _input...
Python
import logging from errorcodes import GeneralError """ Module for logging facilities. """ class Logger(logging.Logger): """ Base class of loggers, derived from logging.Logger. """ def raiseLog(self, exceptionClass, msg): """ Convenience method for raise an exception after logging the incident. "...
Python
import simplejson import os from errorcodes import GeneralError import loggable """ This module handles all the component related classes. """ class ComponentReader(loggable.Loggable): """ This class is responsible for reading a component configuration. """ def __init__(self, compName, _fd, logger): ...
Python
""" This module is the basic module for all the Abacum magic. """
Python
""" Module that provides custom errors. """ class NotYetSupportedError(Exception): """ This error raises when something is not implemented yet. """ pass class GeneralError(Exception): """ This is the main error for all the abacum system. """ pass
Python
import component """ Module for objects that execute code. """ class Programable(component.Component): """ Base class for all the programable objects. Is a derived class from component. """
Python
#!/usr/bin/python2.4 # -*- coding: UTF-8 -*- # subversion info: # $HeadURL: $ # $Author: $ # $Id: $ # $Revision: $ from distutils.core import setup import os import sys import setuptools class doc(setuptools.Command): description = 'Create the package\'s documentation' user_options = [] doc_src = "Abacum" d...
Python
"""Run all unittests. Usage: python3 runtests.py [-v] [-q] [pattern] ... Where: -v: verbose -q: quiet pattern: optional regex patterns to match test ids (default all tests) Note that the test id is the fully qualified name of the test, including package, module, class and method, e.g. 'tests.events_test.Poli...
Python
import os from distutils.core import setup, Extension extensions = [] if os.name == 'nt': ext = Extension('_overlapped', ['overlapped.c'], libraries=['ws2_32']) extensions.append(ext) setup(name='tulip', description="reference implementation of PEP 3156", url='http://www.python.org/dev/peps/pep-31...
Python
"""Event loop and event loop policy. Beyond the PEP: - Only the main thread has a default event loop. """ __all__ = ['AbstractEventLoopPolicy', 'DefaultEventLoopPolicy', 'AbstractEventLoop', 'TimerHandle', 'Handle', 'make_handle', 'get_event_loop_policy', 'set_event_loop_policy', 'get...
Python
"""A socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. """ import socket import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('winsocketpair is win32 only') def socketpair(family=socket.AF_INET, type=socket.SOCK_STR...
Python
"""Queues""" __all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'JoinableQueue'] import collections import concurrent.futures import heapq import queue from . import events from . import futures from . import locks from .tasks import coroutine class Queue: """A queue, useful for coordinating producer and consum...
Python
"""Event loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. """ import collections import socket try: import ssl except ImportError: # pragma: no cover ssl = None from . ...
Python
"""Constants.""" LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
Python
"""Abstract Protocol class.""" __all__ = ['Protocol', 'DatagramProtocol'] class BaseProtocol: """ABC for base protocol class. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is writ...
Python
"""Tulip logging configuration""" import logging tulip_log = logging.getLogger("tulip")
Python
"""Parser is a generator function. Parser receives data with generator's send() method and sends data to destination DataBuffer. Parser receives ParserBuffer and DataBuffer objects as a parameters of the first send() call, all subsequent send() calls should send bytes objects. Parser sends parsed 'term' to desitnation...
Python
# NOTE: This is a hack. Andrew Svetlov is working in a proper # subprocess management transport for use with # connect_{read,write}_pipe(). import fcntl import os import traceback from . import transports from . import events from .log import tulip_log class UnixSubprocessTransport(transports.Transport): """Tr...
Python
"""client session support.""" __all__ = ['Session'] import tulip import http.cookies class Session: def __init__(self): self._conns = {} self.cookies = http.cookies.SimpleCookie() def __del__(self): self.close() def close(self): """Close all opened transports.""" ...
Python
"""HTTP Client for Tulip. Most basic usage: response = yield from tulip.http.request('GET', url) response['Content-Type'] == 'application/json' response.status == 200 content = yield from response.content.read() """ __all__ = ['request'] import base64 import email.message import http.client import http.coo...
Python
"""Http related helper utils.""" __all__ = ['HttpMessage', 'Request', 'Response', 'RawRequestMessage', 'RawResponseMessage', 'http_request_parser', 'http_response_parser', 'http_payload_parser'] import collections import functools import http.server import itertools import re import s...
Python
"""simple http server.""" __all__ = ['ServerHttpProtocol'] import http.server import inspect import logging import traceback import tulip from tulip.http import errors RESPONSES = http.server.BaseHTTPRequestHandler.responses DEFAULT_ERROR_MESSAGE = """ <html> <head> <title>{status} {reason}</title> </head>...
Python
"""WebSocket protocol versions 13 and 8.""" __all__ = ['WebSocketParser', 'WebSocketWriter', 'do_handshake', 'Message', 'WebSocketError', 'MSG_TEXT', 'MSG_BINARY', 'MSG_CLOSE', 'MSG_PING', 'MSG_PONG'] import base64 import binascii import collections import hashlib import struct from tulip.http i...
Python
"""http related errors.""" __all__ = ['HttpException', 'HttpStatusException', 'IncompleteRead', 'BadStatusLine', 'LineTooLong', 'InvalidHeader'] import http.client class HttpException(http.client.HTTPException): code = None headers = () class HttpStatusException(HttpException): def __init...
Python
# This relies on each of the submodules having an __all__ variable. from .client import * from .errors import * from .protocol import * from .server import * from .session import * from .wsgi import * __all__ = (client.__all__ + errors.__all__ + protocol.__all__ + server.__all__ + ...
Python
"""wsgi server. TODO: * proxy protocol * x-forward security * wsgi file support (os.sendfile) """ __all__ = ['WSGIServerHttpProtocol'] import inspect import io import os import sys from urllib.parse import unquote, urlsplit import tulip import tulip.http from tulip.http import server class WSGIServerHttpPro...
Python
"""Selector and proactor eventloops for Windows.""" import errno import socket import weakref import struct import _winapi from . import futures from . import proactor_events from . import selector_events from . import winsocketpair from . import _overlapped from .log import tulip_log __all__ = ['SelectorEventLoop'...
Python
"""Support for tasks, coroutines and the scheduler.""" __all__ = ['coroutine', 'task', 'taskify', 'Task', 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED', 'wait', 'as_completed', 'sleep', ] import concurrent.futures import functools import inspect import time from . import futu...
Python
"""Stream-related things.""" __all__ = ['StreamReader'] import collections from . import futures from . import tasks class StreamReader: def __init__(self, limit=2**16): self.limit = limit # Max line length. (Security feature.) self.buffer = collections.deque() # Deque of bytes objects. ...
Python
"""Tulip 2.0, tracking PEP 3156.""" import sys # This relies on each of the submodules having an __all__ variable. from .futures import * from .events import * from .locks import * from .transports import * from .parsers import * from .protocols import * from .streams import * from .tasks import * if sys.platform ==...
Python
"""Select module. This module supports asynchronous I/O on multiple file descriptors. """ import sys from select import * from .log import tulip_log # generic events, that must be mapped to implementation-specific ones # read event EVENT_READ = (1 << 0) # write event EVENT_WRITE = (1 << 1) def _fileobj_to_fd(fil...
Python
"""Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. """ from . import base_events from . import constants from . import transports from .log import tulip_log class _ProactorSocketTransport(transports....
Python
"""Base implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of IO events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a ca...
Python
"""Selector eventloop for Unix with signal handling.""" import errno import fcntl import os import socket import sys try: import signal except ImportError: # pragma: no cover signal = None from . import constants from . import events from . import selector_events from . import transports from .log import tu...
Python
"""Abstract Transport class.""" __all__ = ['ReadTransport', 'WriteTransport', 'Transport'] class BaseTransport: """Base ABC for transports.""" def __init__(self, extra=None): if extra is None: extra = {} self._extra = extra def get_extra_info(self, name, default=None): ...
Python
"""Synchronization primitives""" __all__ = ['Lock', 'EventWaiter', 'Condition', 'Semaphore'] import collections import time from . import events from . import futures from . import tasks class Lock: """The class implementing primitive lock objects. A primitive lock is a synchronization primitive that is n...
Python
"""A Future class similar to the one in PEP 3148.""" __all__ = ['CancelledError', 'TimeoutError', 'InvalidStateError', 'InvalidTimeoutError', 'Future', ] import concurrent.futures._base import logging import traceback from . import events from .log import tulip_log # States for Futu...
Python
"""Tests for http/wsgi.py""" import io import unittest import unittest.mock import tulip from tulip.http import wsgi from tulip.http import protocol class HttpWsgiServerProtocolTests(unittest.TestCase): def setUp(self): self.loop = tulip.new_event_loop() tulip.set_event_loop(self.loop) ...
Python
"""Tests for http/parser.py""" from collections import deque import zlib import unittest import unittest.mock import tulip from tulip.http import errors from tulip.http import protocol class ParseHeadersTests(unittest.TestCase): def test_parse_headers(self): hdrs = ('', 'test: line\r\n', ' continue\r\n...
Python
"""Tests for tasks.py.""" import concurrent.futures import time import unittest import unittest.mock from tulip import events from tulip import futures from tulip import tasks class Dummy: def __repr__(self): return 'Dummy()' def __call__(self, *args): pass class TaskTests(unittest.TestC...
Python
"""Tests for tulip/http/session.py""" import http.cookies import unittest import unittest.mock import tulip import tulip.http from tulip.http.client import HttpResponse from tulip.http.session import Session class HttpSessionTests(unittest.TestCase): def setUp(self): self.loop = tulip.new_event_loop()...
Python
"""Tests for streams.py.""" import unittest from tulip import events from tulip import streams from tulip import tasks class StreamReaderTests(unittest.TestCase): DATA = b'line1\nline2\nline3\n' def setUp(self): self.loop = events.new_event_loop() events.set_event_loop(self.loop) def ...
Python
"""Tests for base_events.py""" import concurrent.futures import logging import socket import time import unittest import unittest.mock from tulip import base_events from tulip import events from tulip import futures from tulip import protocols from tulip import tasks class BaseEventLoopTests(unittest.TestCase): ...
Python
# NOTE: This is a hack. Andrew Svetlov is working in a proper # subprocess management transport for use with # connect_{read,write}_pipe(). """Tests for subprocess_transport.py.""" import logging import unittest from tulip import events from tulip import futures from tulip import protocols from tulip import subproc...
Python
"""Tests for futures.py.""" import unittest import unittest.mock from tulip import events from tulip import futures def _fakefunc(f): return f class FutureTests(unittest.TestCase): def setUp(self): self.loop = events.new_event_loop() events.set_event_loop(self.loop) def tearDown(self...
Python
"""Http client functional tests.""" import gc import io import os.path import http.cookies import unittest import tulip import tulip.http from tulip import test_utils from tulip.http import client class HttpClientFunctionalTests(unittest.TestCase): def setUp(self): self.loop = tulip.new_event_loop() ...
Python
"""Tests for queues.py""" import unittest import queue from tulip import events from tulip import futures from tulip import locks from tulip import queues from tulip import tasks class _QueueTestBase(unittest.TestCase): def setUp(self): self.loop = events.new_event_loop() events.set_event_loop(...
Python
"""Tests for parser.py""" import unittest import unittest.mock from tulip import events from tulip import parsers from tulip import tasks class StreamBufferTests(unittest.TestCase): DATA = b'line1\nline2\nline3\n' def setUp(self): self.loop = events.new_event_loop() events.set_event_loop(s...
Python
"""Tests for events.py.""" import concurrent.futures import gc import io import os import re import signal import socket try: import ssl except ImportError: ssl = None import sys import threading import time import errno import unittest import unittest.mock from test.support import find_unused_port from tuli...
Python
"""Tests for http/server.py""" import unittest import unittest.mock import tulip from tulip.http import server from tulip.http import errors class HttpServerProtocolTests(unittest.TestCase): def setUp(self): self.loop = tulip.new_event_loop() tulip.set_event_loop(self.loop) def tearDown(se...
Python
"""Tests for http/protocol.py""" import unittest import unittest.mock import zlib from tulip.http import protocol class HttpMessageTests(unittest.TestCase): def setUp(self): self.transport = unittest.mock.Mock() def test_start_request(self): msg = protocol.Request( self.transpo...
Python
"""Tests for selectors.py.""" import unittest import unittest.mock from tulip import selectors class BaseSelectorTests(unittest.TestCase): def test_fileobj_to_fd(self): self.assertEqual(10, selectors._fileobj_to_fd(10)) f = unittest.mock.Mock() f.fileno.return_value = 10 self.a...
Python
"""Tests for winsocketpair.py""" import unittest import unittest.mock from tulip import winsocketpair class WinsocketpairTests(unittest.TestCase): def test_winsocketpair(self): ssock, csock = winsocketpair.socketpair() csock.send(b'xxx') self.assertEqual(b'xxx', ssock.recv(1024)) ...
Python
"""Tests for lock.py""" import time import unittest import unittest.mock from tulip import events from tulip import futures from tulip import locks from tulip import tasks from tulip.test_utils import run_once class LockTests(unittest.TestCase): def setUp(self): self.loop = events.new_event_loop() ...
Python
"""Tests for selector_events.py""" import errno import socket import unittest import unittest.mock try: import ssl except ImportError: ssl = None from tulip import futures from tulip import selectors from tulip.events import AbstractEventLoop from tulip.protocols import DatagramProtocol, Protocol from tulip.s...
Python
# -*- coding: utf-8 -*- """Tests for tulip/http/client.py""" import unittest import unittest.mock import urllib.parse import tulip import tulip.http from tulip.http.client import HttpRequest, HttpResponse class HttpResponseTests(unittest.TestCase): def setUp(self): self.loop = tulip.new_event_loop() ...
Python
"""Tests for unix_events.py.""" import errno import io import unittest import unittest.mock try: import signal except ImportError: signal = None from tulip import events from tulip import futures from tulip import protocols from tulip import unix_events @unittest.skipUnless(signal, 'Signals are not support...
Python
"""Tests for proactor_events.py""" import socket import unittest import unittest.mock import tulip from tulip.proactor_events import BaseProactorEventLoop from tulip.proactor_events import _ProactorSocketTransport class ProactorSocketTransportTests(unittest.TestCase): def setUp(self): self.loop = unitt...
Python
"""Tests for http/websocket.py""" import base64 import hashlib import os import struct import unittest import unittest.mock import tulip from tulip.http import websocket, protocol, errors class WebsocketParserTests(unittest.TestCase): def test_parse_frame(self): buf = tulip.ParserBuffer() p = w...
Python
"""Tests for transports.py.""" import unittest import unittest.mock from tulip import transports class TransportTests(unittest.TestCase): def test_ctor_extra_is_none(self): transport = transports.Transport() self.assertEqual(transport._extra, {}) def test_get_extra_info(self): tran...
Python
"""Search for lines >= 80 chars or with trailing whitespace.""" import sys, os def main(): args = sys.argv[1:] or os.curdir for arg in args: if os.path.isdir(arg): for dn, dirs, files in os.walk(arg): for fn in sorted(files): if fn.endswith('.py'): ...
Python
#!/usr/bin/env python3 """Protocol parser example.""" import argparse import collections import tulip try: import signal except ImportError: signal = None MSG_TEXT = b'text:' MSG_PING = b'ping:' MSG_PONG = b'pong:' MSG_STOP = b'stop:' Message = collections.namedtuple('Message', ('tp', 'data')) def my_proto...
Python
#!/usr/bin/env python3 import sys import tulip import tulip.http def curl(url): response = yield from tulip.http.request('GET', url) print(repr(response)) data = yield from response.read() print(data.decode('utf-8', 'replace')) if __name__ == '__main__': if '--iocp' in sys.argv: from t...
Python
#!/usr/bin/env python3 """websocket cmd client for wssrv.py example.""" import argparse import base64 import hashlib import os import signal import sys import tulip import tulip.http from tulip.http import websocket import tulip.selectors WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" def start_client(loop, url):...
Python
#!/usr/bin/env python3 import logging import re import signal import sys import urllib.parse import tulip import tulip.http class Crawler: def __init__(self, rooturl, loop, maxtasks=100): self.rooturl = rooturl self.loop = loop self.todo = set() self.busy = set() self.do...
Python
#!/usr/bin/env python3 """Multiprocess WebSocket http chat example.""" import argparse import os import socket import signal import time import tulip import tulip.http from tulip.http import websocket ARGS = argparse.ArgumentParser(description="Run simple http server.") ARGS.add_argument( '--host', action="store"...
Python
#!/usr/bin/env python3 """Simple multiprocess http server written using an event loop.""" import argparse import email.message import os import socket import signal import time import tulip import tulip.http from tulip.http import websocket ARGS = argparse.ArgumentParser(description="Run simple http server.") ARGS.ad...
Python
#!/usr/bin/env python3 """TCP echo server example.""" import argparse import tulip try: import signal except ImportError: signal = None class EchoServer(tulip.Protocol): TIMEOUT = 5.0 def timeout(self): print('connection timeout, closing.') self.transport.close() def connection_...
Python
#!/usr/bin/env python3 """Simple server written using an event loop.""" import argparse import email.message import logging import os import sys try: import ssl except ImportError: # pragma: no cover ssl = None assert sys.version >= '3.3', 'Please use Python 3.3 or higher.' import tulip import tulip.http ...
Python
#!/usr/bin/env python3 """UDP echo example.""" import argparse import sys import tulip try: import signal except ImportError: signal = None class MyServerUdpEchoProtocol: def connection_made(self, transport): print('start', transport) self.transport = transport def datagram_received(...
Python
#!/usr/bin/env python import numpy import pylab from math import factorial from matplotlib.font_manager import FontProperties as FP #import nc_broadcast_probability as ncbp import unicast_probability as ucp import broadcast_probability as bcp fp = FP() fp.set_size('small') ### SPECIFICATIONS: ### node_count = 10 pa...
Python
#!/usr/bin/env python import numpy as np import time import os def enc_expanding_windows(windows, generation_size, field_size): window_size = windows[np.random.randint(len(windows))] enc = np.random.randint(field_size, size=(1,window_size)) zeros = np.zeros((1,generation_size-window_size)) enc_vector = np.hstack(...
Python
#!/usr/bin/env python import numpy as np import time import os def enc_expanding_windows(windows, generation_size, field_size): window_size = windows[np.random.randint(len(windows))] enc = np.random.randint(field_size, size=(1,window_size)) zeros = np.zeros((1,generation_size-window_size)) enc_vector = np.hstack(...
Python
#!/usr/bin/env python import random from math import factorial class node(object): def __init__(self): self.has_packet = False def receive_packet(self, succesrate): if random.random() <= succesrate: self.has_packet = True def reset(self): self.has_packet = False def bc_probability_after_transmissi...
Python
#!/usr/bin/env python import random import numpy as np from math import factorial class node(object): def __init__(self, ID): self.has_packet = False self.received_packets = 0 self.id = ID def receive_packet(self, succesrate): if random.random() <= succesrate: self.has_packet = True self.received_pa...
Python
#!/usr/bin/env python import numpy import pylab from math import factorial from matplotlib.font_manager import FontProperties as FP #import nc_broadcast_probability as ncbp import unicast_probability as ucp import broadcast_probability as bcp fp = FP() fp.set_size('small') ### SPECIFICATIONS: ### node_count = 10 pa...
Python
#!/usr/bin/env python import random from math import factorial class node(object): def __init__(self): self.has_packet = False def receive_packet(self, succesrate): if random.random() <= succesrate: self.has_packet = True def reset(self): self.has_packet = False def bc_probability_after_transmissi...
Python
#!/usr/bin/env python import random from math import factorial class node(object): def __init__(self): self.has_packet = False def receive_packet(self, succesrate): if random.random() <= succesrate: self.has_packet = True def reset(self): self.has_packet = False def uc_probability_after_transmissi...
Python
#!/usr/bin/env python import numpy import pylab from math import factorial from matplotlib.font_manager import FontProperties as FP import nc_broadcast_probability as ncbp import broadcast_probability as bcp fp = FP() fp.set_size('small') ### SPECIFICATIONS: ### node_count = 10 packets_needed = 100 packet_range = ...
Python
#!/usr/bin/env python import sys sys.path.insert(0,'../expanding_windows') from expanding_windows import * def enc_non_overlapping_windows(wndws, generation_size, field_size): # Create encoding vector of list of window borders (start and ending borders (0, 'generation_size') should be omitted) windows = wndws if...
Python
#!/usr/bin/env python import sys sys.path.insert(0,'../expanding_windows') from expanding_windows import * def enc_non_overlapping_windows(wndws, generation_size, field_size): # Create encoding vector of list of window borders (start and ending borders (0, 'generation_size') should be omitted) windows = wndws if...
Python
#!/usr/bin/env python import numpy import pylab from math import factorial from matplotlib.font_manager import FontProperties as FP import nc_broadcast_probability as ncbp import broadcast_probability as bcp fp = FP() fp.set_size('small') ### SPECIFICATIONS: ### node_count = 10 packets_needed = 100 packet_range = ...
Python