Exemple #1
0
    def get_stream(self, x0, y0, nmax=100000, lmax=None, stype='v'):
        import stream as s

        if lmax != None:
            lmax_f = lmax
        else:
            lmax_f = 2*np.pi*y0

        if stype == 'v':
            v1 = self.gasvx.get_harddata()
            x1 = self.gasvx.get_x()
            y1 = self.gasvx.get_y()
            v2 = self.gasvy.get_harddata()
            x2 = self.gasvy.get_x()
            y2 = self.gasvy.get_y()
        elif stype == 'b':
            v1 = self.bx.get_harddata()
            x1 = self.bx.get_x()
            y1 = self.bx.get_y()
            v2 = self.by.get_harddata()
            x2 = self.by.get_x()
            y2 = self.by.get_y()
        elif stype == 'd':
            v1 = self.dx.get_harddata()
            x1 = self.dx.get_x()
            y1 = self.dx.get_y()
            v2 = self.dy.get_harddata()
            x2 = self.dy.get_x()
            y2 = self.dy.get_y()
        else:
            print "The allowed options are: v, b & d."
            return None

        stream1 = s.stream(v1, x1, y1, v2, x2, y2, x0, y0, nmax, lmax_f, 1)
        stream2 = s.stream(v1, x1, y1, v2, x2, y2, x0, y0, nmax, lmax_f, -1)
        
        s1 = range(0,len(stream1[0]),1)
        s2 = range(0,-len(stream2[0]),-1)

        ind = np.argsort(s1+s2)

        stream_x = np.array(stream1[0]+stream2[0])[ind]
        stream_y = np.array(stream1[1]+stream2[1])[ind]

        if lmax != None:
            x = stream_y*np.cos(stream_x)
            y = stream_y*np.sin(stream_x)
            dx = x[1:]-x[:-1]
            dy = y[1:]-y[:-1]
            l = np.cumsum(np.sqrt(dx**2+dy**2))
            i = np.where(l<lmax)
            return [stream_x[i],stream_y[i]]
        else:
            return [stream_x,stream_y]
Exemple #2
0
def stream(S,x0,y0,nmax=10000,sign=1):
    """
    A SnapShot Wrapper for the stream module.
    """

    lista = s.stream(S.gasvx.data, S.gasvx.x, S.gasvx.y,
                     S.gasvy.data, S.gasvy.x, S.gasvy.y,
                     x0,y0,nmax,sign)

    return lista
Exemple #3
0
def main():
    global opcode
    global dispEQ
    global dispIP
    global eqstream

    eqstream = stream.stream()


    dispEQ = True
    dispIP = False


    opcode = opmanager.OpcodePacket()


    parser=OptionParser()
    parser.add_option("-n", dest="npackets", type="int",\
                      help="Number of packets to sniff")
    (options, args)=parser.parse_args()
    s=socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)

    try:
        # get the current Network Interface
        host=socket.gethostbyname(socket.gethostname())
        s.bind((host, 0))
        # Enable the Promiscuous mode
        s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
        if options.npackets!=None:
            for i in range(options.npackets):
                sniff(s,"66.55.145.2")
        else:
            while True:
                sniff(s,"66.55.145.2")
    except socket.error as err:
        print("[-] Error: %s"%str(err))
    except KeyboardInterrupt:
        print("[+] Keyboard Interruption captured: Existing")

    # Disable the Promiscuous mode
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
    s.close()
Exemple #4
0
    def __inst_repr__(self, id):
        s = StringIO()
        f = stream.stream(s)
        f.write('register #(%d, %d) REG%s(' %
                (self.width(), self.rst_value, id))
        more_than_one = False
        indented = False
        decls = self.decls()
        for k in decls:
            p = decls[k]
            if p.dxn() is not None:
                if more_than_one:
                    f.writenl(',', i=0)
                    if not indented:
                        f.indent()
                        indented = True
                f.write('.%s(%s)' %
                        (self.cxnport(p.name()), self.cxnname(p.name())))
                more_than_one = True

        f.unindent()
        f.writenl(');')

        return s.getvalue()
def online_depth(sender, tree_name=None, edge=None):
    with conn.lock('{0}.depth'.format(tree_name)):
        current_depth = conn.get('{0}.depth'.format(tree_name)) or 0
        if int(current_depth) < edge.generation:
            conn.set('{0}.depth'.format(tree_name), edge.generation)

"""
Subscribe our online methods to the node_added event.
"""
signal('node_added').connect(online_size)
signal('node_added').connect(online_depth)

"""
Start the stream and grow the tree(s)!
"""
datastream = stream(nodes=10)
tree = grow_trees(datastream)

"""
Well... We can't have absolutely zero tests....
"""
roots = tree.get_roots()
depth = 0
for root in roots:
    depth = max(depth, tree.get_depth(root))

"""
Check online calculations
"""
# Labels the generation of the child, starts at 0, hence the +2.
print "Online Depth", int(conn.get('MyTree.depth')) + 2 
Exemple #6
0
 def ast_args(self, stm):
     syntax_assert(stm.peek(), "PARN", "need parenthese")
     t = self.ast_parn(stream(stm.next().val))
     t["type"] = "ARGS"
     return t
Exemple #7
0
def PlotStream(x1, y1, vx, vy, o):
    psi = stream.stream(vx, vy)
    fig, ax = PlotInit()
    plt.contour(x1, y1, psi, 36, colors='k', linestyles="solid", linewidths=1.)
    ax.imshow(np.flipud(p), extent=(0, 1, 0, 1), interpolation='nearest')
    PlotSave2(fig, ax, o)
Exemple #8
0
        'ip addr show', shell=True, stdout=subprocess.PIPE)
    addresses = re.findall(addr_pattern, str(process_output.stdout))
    if constants.central_server in addresses:
        config = constants.central_server
        return config
    for camera in constants.cameras:
        if constants.cameras[camera]['address'] in addresses:
            config = constants.cameras[camera]
    if not config:
        sys.exit(1)
    return config


if __name__ == "__main__":
    fileformat = '{"time": "%(asctime)s", "source": "%(name)s", "level": "%(levelname)s", "details": %(message)s}'
    handler = TimedRotatingFileHandler(constants.log_path + "/camera.log", when="midnight", interval=1, backupCount=5)
    logging.basicConfig(format=fileformat, filename=constants.log_path + "/camera.log")
    logger = logging.getLogger("FFStreamerCapture")
    logger.setLevel(logging.DEBUG)
    logger.info("\"action\": \"Initiated FFStreamerCapture\"")
    logger.addHandler(handler)
    config = find_config()
    if config == constants.central_server:
        logger.info("\"role\": \"central_server\"")
        import receive
        receive.receive(constants.cameras)
    else:
        logger.info("\"role\": \"remote_camera\"")
        import stream
        stream.stream(config)
Exemple #9
0
def viewstreams():
    team = request.form['team']
    l = stream(team)
    # links = []
    print (l)
    return render_template("streams.html", team = team, links = l)
 def Event_Continue( self, event = None):
     stream(self.file_name)
     self.main.myParent.destroy()
     self.master.destroy()
Exemple #11
0
		print repr(e)
	except jack.OutputSyncError, e:
		print repr(e)


	micsplit = numpy.vsplit(microphones,channels)
	
	out = list()
	for x in range(channels):
		out.append([numpy.zeros((1,bufsize),'f')])
		
	
	if loop > 10:
		if not b: 
			#b = capetalk.capetalk()
			b = stream.stream('220')
		data = b.getsomestream(bufsize)
		out[1].append(data)
		out[0].append(data)	
	else: 
		out[0].append(micsplit[0])
	
	
	out[1].append(micsplit[0])
	
	# Blend the outputs
	for x in range(channels):		
		count = len(out[x])
		if count == 1:
			out[x] = out[x][0] # Straight out
		if count > 1:
 def connect(self):
     self.close()
     self.dispatcher_socket = socket.create_connection(self.dispatcher_addr)
     self.register()
     self.dispatcher_stream = stream(self.dispatcher_socket, 10)
Exemple #13
0
import stream
import signature
import cv2
import numpy as np
import os

stream.stream()
#stream.concatinate1()
# os.chdir('C:/Users/Кирилл/Desktop/video')
#keys = signature.genKeys(160)
# signature.writekeytofile('vid1.avi', keys[1])
# f = open('./openkeys/vid1.aviopenkey.txt','r')
# list = f.read()
# print(list)
Exemple #14
0
 def initoutflow(self):
     self.outflow = [stream.stream] * self.nout
     for i in range(self.nout):
         self.outflow[i] = stream.stream(0, self.location.x,
                                         self.location.y, self.location.x,
                                         self.location.y)
Exemple #15
0
 def initinflow(self):
     self.inflow = [stream.stream] * self.nin
     for i in range(self.nin):
         self.inflow[i] = stream.stream(0, self.location.x, self.location.y,
                                        self.location.x, self.location.y)
Exemple #16
0
	def __define_repr__(self):
		s = StringIO()
		f = stream.stream(s)
		for member in self.members():
			f.writenl(member.__declare_repr__())	
		return s.getvalue()
Exemple #17
0
	def newstate(self,state,param1=None):
		if state == self.state: return
		
		
		duration = float(self.gettime()) - float(self.laststatesince)
		self.laststatesince = self.gettime()
		print "duration", duration
		if duration > 1:
			calllog.calllog(self.id, self.number(), duration ,self.state)
				
		
		if state not in valid_states:
			raise Exception(state+" is not a valid state.")
			
		# Old states
		if self.state in ('stream'): 
			self.stream.__del__()
			self.stream = None
			
		if self.state == 'comment':
			self.commentfile.close()
			# Now email someone
		
		
		
		self.onhooksince = self.gettime()		
		
		# Change state
		self.state = state
		
		# New states
		print self.name+" is in state: "+self.state
		if self.state in ('onhook', 'dialtone'):
			self.numberdialled = list()
		
		if self.state == 'dialtone':
			self.addplay(soundfile.welcome, True)
			
		if self.state == 'busy':
			self.addplay(soundfile.busy, True)
			
		if self.state == 'onhook':
			self.addplay(None, True)
			
		if self.state == 'stream':
			self.addplay(None, True)
			self.stream = stream.stream(streamname=param1)
			
		if self.state == 'incall':
			self.addplay(None, True)
		
		if self.state == 'ringing':
			self.addplay(soundfile.buzz, True)
			#self.addplay(soundfile.telephonering, True)
			#subprocess.check_call(['/bin/bash','-c','/usr/bin/lynx -source http://commando.nitric.co.za/ring.php > /dev/null &'])
			
		if self.state == 'comment':
			self.addplay(soundfile.leavecomment, True)
			self.addplay(None)
			self.commentfile = open("comments/"+str(self.id)+"_"+str(time.time())+".raw", "w")
			print "Saving comments to file."
			
		if self.state == 'closed':
			self.addplay(None, True)
			self.addplay(soundfile.goodbye, True)
Exemple #18
0
#COPY:  Copyright 2018, All Rights Reserved, Ryan McCartney

from stream import stream
from threading import Thread
from queue import Queue
import cv2 as cv
import json
import time
import random

settings_location = "streams/nestBoxStream.json"
minShotLength = 3
maxShotLength = 15

# Class instances for various streams
liveStream = stream(settings_location, minShotLength, maxShotLength)

#Start Clock
liveStream.getTime()

#Start Text Render
liveStream.textRender()

#Start programStream
#liveStream.streamProgram()

setScene = False
setBanner = False
delay = 10
text = [
    "Changing scene in X seconds", "Now view A SHOT DESCRIPTION",
 def Event_Zero(self, event = None):
     stream("zero.gcode")
Exemple #20
0
    def copyfrom(self, simcopyfrom):
        #//MemoryStream myStream = new MemoryStream();
        #//simulation tempsim = new simulation();
        #//BinaryFormatter bf = new BinaryFormatter();
        #//bf.Serialize(myStream, simcopyfrom);
        #//myStream.Seek(0, SeekOrigin.Begin);
        #//tempsim = (simulation)bf.Deserialize(myStream);
        #//myStream.Close();
        #//unitops = tempsim.unitops;
        #//streams = tempsim.streams;
        #//pidcontrollers = tempsim.pidcontrollers;
        if (len(self.unitops) == 0):
            self.unitops = []
            for i in range(len(simcopyfrom.unitops)):
                #if simcopyfrom.unitops[i].objecttype == globe.objecttypes.CoolingTowerSimple:
                #    #obj = coolingtowersimple()
                #    obj.coolingtowersimplecopyconstructor(simcopyfrom.unitops[i])
                #    self.unitops.append(obj)
                #elif simcopyfrom.unitops[i].objecttype == globe.objecttypes.CoolingTowerHeatExchangerSimple:
                #    obj = coolingtowerheatexchangersimple()
                #    obj.coolingtowerheatexchangersimplecopyconstructor(simcopyfrom.unitops[i])
                #    self.unitops.append(obj)
                if simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.CoolingTower:
                    obj = coolingtower(0, 0, 0)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                #elif simcopyfrom.unitops[i].objecttype == globe.objecttypes.DistillationColumn:
                #    obj = distillationcolumn()
                #    obj.copyfrom(simcopyfrom.unitops[i])
                #   self.unitops.append(obj)
                #elif simcopyfrom.unitops[i].objecttype == globe.objecttypes.Flange:
                #    obj = flange()
                #    obj.flangecopyconstructor(simcopyfrom.unitops[i])
                #    self.unitops.append(obj)
                #elif simcopyfrom.unitops[i].objecttype == globe.objecttypes.GasPipe:
                #   obj = gaspipe()
                #   obj.gaspipecopyconstructor(simcopyfrom.unitops[i])
                #    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.HeatExchangerSimple:
                    obj = heatexchangersimple(0, 0, 0)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.Mixer:
                    obj = mixer(0, 0, 0, simcopyfrom.unitops[i].nin)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.Pump:
                    obj = pump(0.0, 0.0, 0.0, 0.0, 0.0, \
                            0.0, 0.0, 1)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.Tee:
                    obj = tee(0.0, 0.0, 0.0, simcopyfrom.unitops[i].nout)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.Valve:
                    obj = valve(0, 0.0, 0.0)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                elif simcopyfrom.unitops[
                        i].objecttype == globe.objecttypes.Tank:
                    obj = tank(0, 0.0, 0.0)
                    obj.copyfrom(simcopyfrom.unitops[i])
                    self.unitops.append(obj)
                else:
                    break
        else:
            for i in range(len(simcopyfrom.unitops)):
                self.unitops[i].copyfrom(simcopyfrom.unitops[i])

        if (len(self.streams) == 0):
            self.streams = []
            for i in range(len(simcopyfrom.streams)):
                obj = stream(0, 0.0, 0.0, 0.0, 0.0)
                obj.copyfrom(simcopyfrom.streams[i])
                self.streams.append(obj)
        else:
            for i in range(len(simcopyfrom.streams)):
                self.streams[i].copyfrom(simcopyfrom.streams[i])

        #if (len(self.signals) == 0):
        #    self.signals = []
        #    for i in range(len(simcopyfrom.signals)):
        #        obj = signal()
        #       obj.copyfrom(simcopyfrom.signals[i])
        #        self.signals.append(obj)
        #else:
        #    for i in range(len(simcopyfrom.signals)):
        #        self.signals[i].copyfrom(simcopyfrom.signals[i])

        if (len(self.pidcontrollers) == 0):
            self.pidcontrollers = []
            for i in range(len(simcopyfrom.pidcontrollers)):
                obj = pidcontroller()
                obj.copyfrom(simcopyfrom.pidcontrollers[i])
                self.pidcontrollers.append(obj)
        else:
            for i in range(len(simcopyfrom.pidcontrollers)):
                self.pidcontrollers[i].copyfrom(simcopyfrom.pidcontrollers[i])

        #if (len(self.blocks) == 0):
        #    self.blocks = []
        #    for i in range(len(simcopyfrom.blocks)):
        #       if simcopyfrom.blocks[i].objecttype == globe.objecttypes.ControlMVSignalSplitter:
        #           obj = controlmvsignalsplitter()
        #           obj.copyfrom(simcopyfrom.blocks[i])
        #           blocks.append(obj)
        #       else:
        #           break
        #else:
        #   for i in range(len(simcopyfrom.blocks)):
        #        self.blocks[i].copyfrom(simcopyfrom.blocks[i])

        #//public List<nmpc> nmpccontrollers; The nmpc controller(s) are not going to be copied at this point in time.
        self.simi = simcopyfrom.simi  #//Counting index for this class for simulation indexing for historisation and simulation.
Exemple #21
0
def evaluate (source):
    return evaluatefomula(parsefomula(parsetokens(stream.stream(source))))
Exemple #22
0
    files = [i for i in os.listdir(path)
             if i.endswith('.mp4')]  # avoid random files
    files = [(s + 1, i) for (s, i) in enumerate(files)
             ]  #Make a enumerated list of the files in the folder
    return iodir(str(file_path[0]), path, files)


def check_ext_name(name):
    split = name.split('.')
    #Check if there is extension
    if (len(split) > 1):
        file_extension = split.pop()
    else:
        file_extension = None
    return split[0], file_extension


if __name__ == "__main__":
    dyr = setDir()  #set directories
    x = int(input("[1]Transcode\n[2]Multiple Video\n[3]Stream\n"))
    while not x == EXIT:
        if x == TRANSCODE:
            dyr.chooseinput(var='file')
            transcode.transcode(dyr.outputFolder, dyr.inp)
        elif x == MULTIPLE:
            dyr.chooseinput(var='folder')
            multipleVideo(dyr.outputFolder, dyr.files)
        elif x == STREAM:
            stream(dyr.path / "cut_BBB.mp4")
        x = int(input("[1]Transcode\n[2]Multiple Video\n[3]Stream\n"))