Exemple #1
0
class MainWindow (QtGui.QMainWindow):

	def __init__ (self, application):
		QtGui.QMainWindow.__init__ (self)

		self.channel = Channel ()
		self.channel.open ()

		self.application = application
		self.setWindowTitle (u'Отладчик')

		main_frame = MainFrame (self)
		self.setCentralWidget (main_frame)

		self.connect (application, QtCore.SIGNAL ('aboutToQuit()'), self.on_quit)

		self.statusBar ().showMessage (u'Готов')

		DebugDataProvider (self)
		DebugDataProvider.receive_data ()
		DebugDataProvider.update_code_text ()

		self.resize (1000, 300)

	def on_quit (self):
		self.channel.close ()
Exemple #2
0
 def create_menu_kill_sink(self):
     Channel.create_menu_kill_sink(self)
     if self.pa_sink.props["driver"] == "module-combine-sink.c":
         action = QAction(i18n("Uncombine"), self.popup_menu)
         self.popup_menu.addAction(action)
         action.triggered.connect(self.stopcombining)
     self.context_menu_create_sounddevices_other()
Exemple #3
0
class MainWindow(QtGui.QMainWindow):
    def __init__(self, application):
        QtGui.QMainWindow.__init__(self)

        self.channel = Channel()
        self.channel.open()

        self.application = application
        self.setWindowTitle(u'Отладчик')

        main_frame = MainFrame(self)
        self.setCentralWidget(main_frame)

        self.connect(application, QtCore.SIGNAL('aboutToQuit()'), self.on_quit)

        self.statusBar().showMessage(u'Готов')

        DebugDataProvider(self)
        DebugDataProvider.receive_data()
        DebugDataProvider.update_code_text()

        self.resize(1000, 300)

    def on_quit(self):
        self.channel.close()
 def create_menu_kill_sink(self):
     Channel.create_menu_kill_sink(self)
     if self.pa_sink.props["driver"]=="module-combine-sink.c":
         action=QAction(i18n("Uncombine"), self.popup_menu)
         self.popup_menu.addAction(action)
         action.triggered.connect(self.stopcombining)
     self.context_menu_create_sounddevices_other()
Exemple #5
0
def test_pushMessage_to_tag():
    c = Channel(apiKey, secretKey)
    push_type = Channel.PUSH_TO_TAG
    tag_name = 'push'
    optional = dict()
    optional[Channel.TAG_NAME] = tag_name
    ret = c.pushMessage(push_type, message, message_key, optional)
    print ret
Exemple #6
0
    def detect_video(self, url):
        res = None
        try:
            res = YouTubeTranscriptApi.get_transcript(url)
        except:
            return "No Subtitles Found"
        videoText = ""
        time = 0
        for output in res:
            videoText += (output['text']) + " "
            time += output['duration']
        print(time / 60)
        OrgValue, ProperValue = NLPProcessor(videoText)
        self.OrgValue = OrgValue
        maxValue = (0, "")
        massiveBucket = correctData(OrgValue, ProperValue)
        for entitiies in OrgValue:
            if massiveBucket[entitiies] == 0:
                continue
            maxValue = max(maxValue, (massiveBucket[entitiies], entitiies))

        print(maxValue[0])
        channelName, ChannelUrl, soup = rc.get_video_info(url)
        if channelName == None:
            self.lastChannel = "ERROR"
            if maxValue[0] >= time / 90:

                return "This video is an advertisement for " + maxValue[1]
            else:
                return "This video is not an advertisement"
        self.lastChannel = channelName
        if channelName not in self.DataSet:
            newChannel = Channel()
            channelRef = self.dataBase.document(channelName).get()

            if channelRef.exists:
                newChannel.get_from_database(channelRef.to_dict())
            else:
                uploadData = newChannel.soup_insert(soup)
                self.dataBase.document(channelName).set(uploadData)
            self.DataSet[channelName] = newChannel
            self.ChannelUrls[ChannelUrl] = channelName
        Freq = self.DataSet[channelName].update_common(massiveBucket)
        self.dataBase.document(channelName).update({u'Freq': Freq})
        rating = self.DataSet[channelName].get_rating()
        if maxValue[0] >= time / 90 - (5 * rating):
            TotalVote = self.DataSet[channelName].down_vote()
            self.dataBase.document(channelName).update(
                {u'TotalVote': TotalVote})

            #print(self.DataSet[channelName].get_rating())
            return "This video is an advertisement for " + maxValue[1]
        upvote, TotalVote = self.DataSet[channelName].up_vote()
        self.dataBase.document(channelName).update({
            u'UpVote': upvote,
            u'TotalVote': TotalVote
        })
        return "This video is not an advertisement"
Exemple #7
0
	def DoConnect(self, address=None):
		if address:
			self.address = address
		try:
			Channel.__init__(self)
			self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
			self.connect(self.address)
		except socket.gaierror, e:
			self.queue.append({"action": "error", "error": e.args})
Exemple #8
0
	def DoConnect(self, address=None):
		if address:
			self.address = address
		try:
			Channel.__init__(self, map=self._map)
			self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
			self.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
			self.connect(self.address)
		except socket.gaierror, e:
			self.queue.append({"action": "error", "error": e.args})
Exemple #9
0
 def DoConnect(self, address=None):
     if address:
         self.address = address
     try:
         Channel.__init__(self, map=self._map)
         self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         self.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
         self.connect(self.address)
     except socket.gaierror, e:
         self.queue.append({"action": "error", "error": e.args})
Exemple #10
0
def test_pushMessage_to_user():
    c = Channel(apiKey, secretKey)
    push_type = Channel.PUSH_TO_USER
    optional = dict()
    optional[Channel.USER_ID] = user_id
    optional[Channel.CHANNEL_ID] = channel_id
    # 推送通知类型
    optional[Channel.MESSAGE_TYPE] = Channel.PUSH_NOTIFICATION
    ret = c.pushMessage(push_type, message, message_key, optional)
    print ret
def do_admin_PUTChannels():
    logger.info("\n\nInvoking admin /PUT/channels, IP: {} ".format(
        request.remote_addr))
    if request.method == "POST":
        channelData = request.get_json()
        newChannel = Channel(channelData)
        newCid = newChannel.initializeUserChannel()

        return jsonify({u'cid': newCid}), 201
    else:
        return jsonify({u'cid': -1}), 400
Exemple #12
0
    def __init__(self):
        # set the name
        self.name_ = "DataSelectorNode"
        self.label_ = ""

        # initial status
        self.status_ = Node.NotReady_

        # Only relevant thing is the output data channel
        self.out_channels_ = [Channel("output", self)]
        self.in_channels_ = [Channel("input1", self), Channel("input2", self)]
Exemple #13
0
 def __init__(self,name, veromix, controller):
     self.controller = controller
     Channel.__init__(self, veromix)
     self.controller.data_updated.connect(self.controller_data_updated)
     self.index = -1
     self._state= None
     self._position = 0
     self._artwork = ""
     self.last_playing_icon = KIcon(self.get_pauseIcon())
     self.layout.setContentsMargins(6,0,6,2)
     self.controller.init_connection()
    def __init__(self):
        # TODO: Protect against being set NotReady by upstream nodes while processing stuff
        # set the name
        self.name_ = "OutputCondNode"
        self.label_ = ""
        self.cond_result_ = None
        self.cond_data_ = None

        # initial status
        self.status_ = Node.NotReady_

        # Provide the input data channel, input test channel and the two outputs
        self.in_channels_ = [Channel("input", self), Channel("test", self)]
        self.out_channels_ = [Channel("false_out", self), Channel("true_out", self)]
    def __init__(self):
        # TODO: Protect against being set NotReady by upstream nodes while processing stuff
        # set the name
        self.name_ = "SplitterNode"
        self.label_ = ""

        # initial status
        self.status_ = Node.NotReady_

        # initial index of the splitter
        self.curr_index_ = 0

        # Provide an input and output data channel
        self.out_channels_ = [Channel("output", self)]
        self.in_channels_ = [Channel("input", self)]
Exemple #16
0
def main():
    # for num_of_err in range(10000,100001,10000):
    #     image = Image_message(test_image_file_name)
    #     corectionCodes = CorectionCodes(image.image_bits)
    #     encoded_message = corectionCodes.hamming_encode(3)
    #     encoded_message_with_errors = Channel.random_error_number(np.concatenate(encoded_message), num_of_err)
    #     encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(len(encoded_message),encoded_message_with_errors)
    #     decoded_message = corectionCodes.hamming_decode(encoded_meassage_with_error_to_decode, 3)
    #     results.add_result(image.image_bits,np.concatenate(encoded_message),decoded_message,'hamming_7-4',num_of_err)
    #     results.print_results()
    # for num_of_err in range(10000,100001,10000):
    #     image = Image_message(test_image_file_name)
    #     corectionCodes = CorectionCodes(image.image_bits)
    #     encoded_message = corectionCodes.hamming_encode(4)
    #     encoded_message_with_errors = Channel.random_error_number(np.concatenate(encoded_message), num_of_err)
    #     encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(len(encoded_message),encoded_message_with_errors)
    #     decoded_message = corectionCodes.hamming_decode(encoded_meassage_with_error_to_decode, 4)
    #     results.add_result(image.image_bits,np.concatenate(encoded_message),decoded_message,'hamming_15-11',num_of_err)
    #     results.print_results()
    # for num_of_err in range(10000,100001,10000):
    #     image = Image_message(test_image_file_name)
    #     corectionCodes = CorectionCodes(image.image_bits)
    #     encoded_message = corectionCodes.hamming_encode(5)
    #     encoded_message_with_errors = Channel.random_error_number(np.concatenate(encoded_message), num_of_err)
    #     encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(len(encoded_message),encoded_message_with_errors)
    #     decoded_message = corectionCodes.hamming_decode(encoded_meassage_with_error_to_decode, 5)
    #     results.add_result(image.image_bits,np.concatenate(encoded_message),decoded_message,'hamming_31-26',num_of_err)
    #     results.print_results()
    # for num_of_err in range(10000,100001,10000):
    #     image = Image_message(test_image_file_name)
    #     corectionCodes = CorectionCodes(image.image_bits)
    #     encoded_message = corectionCodes.hamming_encode(6)
    #     encoded_message_with_errors = Channel.random_error_number(np.concatenate(encoded_message), num_of_err)
    #     encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(len(encoded_message),encoded_message_with_errors)
    #     decoded_message = corectionCodes.hamming_decode(encoded_meassage_with_error_to_decode, 6)
    #     results.add_result(image.image_bits,np.concatenate(encoded_message),decoded_message,'hamming_63-57',num_of_err)
    #     results.print_results()
    # for num_of_err in range(10000,100001,10000):
    #     image = Image_message(test_image_file_name)
    #     corectionCodes = CorectionCodes(image.image_bits)
    #     encoded_message = corectionCodes.hamming_encode(7)
    #     encoded_message_with_errors = Channel.random_error_number(np.concatenate(encoded_message), num_of_err)
    #     encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(len(encoded_message),encoded_message_with_errors)
    #     decoded_message = corectionCodes.hamming_decode(encoded_meassage_with_error_to_decode, 7)
    #     results.add_result(image.image_bits,np.concatenate(encoded_message),decoded_message,'hamming_127-120',num_of_err)
    #     results.print_results()
    for num_of_err in range(100000, 600000, 100000):
        image = Image_message(test_image_file_name)
        corectionCodes = CorectionCodes(image.image_bits)
        encoded_message = corectionCodes.hamming_encode(8)
        encoded_message_with_errors = Channel.random_error_number(
            np.concatenate(encoded_message), num_of_err)
        encoded_meassage_with_error_to_decode = corectionCodes.array_to_decode(
            len(encoded_message), encoded_message_with_errors)
        decoded_message = corectionCodes.hamming_decode(
            encoded_meassage_with_error_to_decode, 8)
        results.add_result(image.image_bits, np.concatenate(encoded_message),
                           decoded_message, 'hamming_255-247', num_of_err)
        results.print_results()
    results.save_to_file("hamming_test.csv")
Exemple #17
0
    def __init__(self,
                 ARRIVE_RATE=None,
                 CHANNEL_RATE=None,
                 TOTAL_PACKET=None,
                 NUMBER_OF_HOST=None):
        config = configparser.ConfigParser()
        config.read("configuration_file.ini")
        self.ARRIVE_RATE = float(config["DEFAULT"]["ARRIVE_RATE"])
        self.NUMBER_OF_HOST = int(config["DEFAULT"]["NUMBER_OF_HOST"])
        self.TOTAL_PACKET = int(config["DEFAULT"]["TOTAL_PACKET"])
        self.CHANNEL_RATE = int(config["DEFAULT"]["CHANNEL_RATE"])

        self.channel = Channel(self.CHANNEL_RATE, self)
        self.host_array = [Host(n, self) for n in range(self.NUMBER_OF_HOST)]
        self._previousEvent = None

        # variables and counters
        self.timeLineEvent = []
        self.counter_array = []
        self.packet_array = []
        self.event_list = deque()
        self.busy_time = 0
        self.current_time = 0
        self.packet_counter = 0
        self.event_counter = 0

        self.number_in_system = []
Exemple #18
0
def cyclic_process(index, codes, ei_n0):
    # Encoding
    cyclic_codes = []
    gen = np.flip(np.array(reader.get_matrix(index)[0]))
    n = len(gen) - PolyDecoder.degree(gen) + 1
    poly_encoder = PolyEncoder(gen)
    for c in range(len(codes) // n):
        cyclic_codes.append(np.array(codes[c * n:c * n + n]))

    encodes = [poly_encoder.encode(code) for code in cyclic_codes]

    # Channeling
    shape = np.shape(reader.get_matrix(index))
    channels = [Channel(p) for p in p_map(ei_n0, shape[0] / shape[1])]
    outputs = [None] * len(channels)
    for c in range(len(channels)):
        outputs[c] = np.array(
            [channels[c].add_noise(code) for code in encodes])

    # Decoding
    poly_decoder = PolyDecoder(gen, len(gen))

    for c in range(len(channels)):
        print("processing_cyclic...")
        outputs[c] = np.array(
            [poly_decoder.decode(code) for code in outputs[c]])
        outputs[c] = outputs[c].flatten()
    print("over")
    return outputs
Exemple #19
0
    def __init__(self, index):
        self.boardIndex = index  # index of the board; should be ordered as the clock distribution order
        self.boardEnable = True  # enable or disable the readout of the entire board

        self.Connection = Connection()
        self.Connection.conetNode = index

        self.IRQPolicy = IRQPolicy()

        self.ChargeMode = ChargeMode()

        self.SAMCorrection = SAMCorrection()
        self.SAMFrequency = 1.6  # sampling rate in GS/s; must be 3.2, 1.6, 0.8, or 0.4

        self.RecordLength = 1024  # number of samples digitized; must be N*16, for 4 <= N <= 256

        self.TriggerType = TriggerType()

        self.IOLevel = IOLevel()

        self.MaxNumEventsBLT = 255  # max number of events to read in each block transfer over optical link

        self.GroupTriggerLogic = GroupTriggerLogic()

        self.TriggerCountVeto = TriggerCountVeto()

        self.groups = [Group() for _ in range(self.numGroups)]
        self.channels = [Channel() for _ in range(self.numChannels)]
Exemple #20
0
def improved_process(P, codes, ei_n0):
    improved_codes = []
    n = P.shape[0]
    # print(n)
    # exit()
    assert len(codes) % n == 0
    for c in range(len(codes) // n):
        improved_codes.append(np.array(codes[c * n:c * n + n]))

    # Encoding
    improved_encoder = Encoder(P)
    encodes = [improved_encoder.encode(code) for code in improved_codes]

    # Channeling
    channels = [
        Channel(p)
        for p in p_map(ei_n0, P.shape[0] / (P.shape[0] + P.shape[1]))
    ]
    outputs = [None] * len(channels)
    for c in range(len(channels)):
        outputs[c] = np.array(
            [channels[c].add_noise(code) for code in encodes])

    # Decoding
    n = P.shape[1] // 3
    improved_decoder = Decoder(P, n + 1)
    for c in range(len(channels)):
        outputs[c] = np.array(
            [improved_decoder.decode(code) for code in outputs[c]])
        print("processing_improved...")
        outputs[c] = outputs[c].flatten()

    return outputs
Exemple #21
0
def leave_channel(data):
    user_name = data['user_name']
    channel = data['channel']
    timestamp = datetime.now().strftime('%x %X')
    leave_room(channel)
    message = f'{user_name} has left {channel}.'

    #Remove flacker from first instance in channel
    try:
        flackers_in_channels.remove({user_name, channel})
    except:
        print(f'{user_name} was not found in {channel}.')

    #Check if user is still in channel from another area (such as a different tab)
    if {user_name, channel} not in flackers_in_channels:
        temp_channel = Channel(channel, 0)
        try:
            ind = channels.index(temp_channel)
            emit('post leave', {
                'user_name': user_name,
                'message': message,
                'timestamp': timestamp
            },
                 room=channel,
                 broadcast=True)
            channels[ind].add_message(user_name, message, timestamp)
        except:
            print(f'Channel {channel} not found, unable to remove user.')
Exemple #22
0
def enter_channel(data):
    user_name = data['user_name']
    channel = data['channel']
    timestamp = datetime.now().strftime('%x %X')
    message = f'{user_name} has joined {channel}!'

    join_room(channel)

    #check if flacker is already in channel (such as a different tab)
    if {user_name, channel} not in flackers_in_channels:
        temp_channel = Channel(channel, 0)
        try:
            ind = channels.index(temp_channel)
            emit('post join', {
                'user_name': user_name,
                'message': message,
                'timestamp': timestamp
            },
                 room=channel,
                 broadcast=True)
            channels[ind].add_message(user_name, message, timestamp)
        except:
            print(f'Channel {channel} not found, unable to add user.')

    #add flacker to channel
    flackers_in_channels.append({user_name, channel})
    def run(self):
        self.log("Starting")
        self.chanlist.exitThread = False
        self.chanlist.readConfig()
        self.chanlist.sleepTime = 0.1
        MEDIA_LOC =  xbmc.translatePath(os.path.join(ADDON_PATH, 'resources', 'skins', 'Default', 'media')) + '/'
        thumb = (DEFAULT_IMAGES_LOC + 'icon.png')

        if self.myOverlay == None:
            self.log("Overlay not defined. Exiting.")
            return
            
        self.chanlist.myOverlay = self.myOverlay
        self.fullUpdating = (self.myOverlay.backgroundUpdating == 0)
        validchannels = 0

        for i in range(self.myOverlay.maxChannels):
            self.chanlist.channels.append(Channel())

            if self.myOverlay.channels[i].isValid:
                validchannels += 1
                
        # Don't load invalid channels if minimum threading mode is on
        if self.fullUpdating and self.myOverlay.isMaster:
            if validchannels < self.chanlist.enteredChannelCount:
                title = 'PseudoTV Live, Background Loading...'
                xbmc.executebuiltin('XBMC.Notification(%s, %s, %s)' % (title, 4000 , thumb))
            for i in range(self.myOverlay.maxChannels):
                if self.myOverlay.channels[i].isValid == False:
                    while True:
                        if self.myOverlay.isExiting:
                            self.log("Closing thread")
                            return

                        time.sleep(1)

                        if self.paused == False:
                            break

                    self.chanlist.channels[i].setAccessTime(self.myOverlay.channels[i].lastAccessTime)

                    try:
                        if self.chanlist.setupChannel(i + 1, True, True, False) == True:
                            while self.paused:
                                if self.myOverlay.isExiting:
                                    self.log("IsExiting")
                                    return

                                time.sleep(1)

                            self.myOverlay.channels[i] = self.chanlist.channels[i]

                            if self.myOverlay.channels[i].isValid == True:
                                title = "PseudoTV Live, Channel " + str(i + 1) + " Added"
                                xbmc.executebuiltin('XBMC.Notification(%s, %s, %s)' % (title, 4000, thumb))
                    except Exception,e:
                        self.log("Unknown Channel Creation Exception", xbmc.LOGERROR)
                        self.log(traceback.format_exc(), xbmc.LOGERROR)
                        return
Exemple #24
0
def normal_process(codes, ei_n0):
    channels = [Channel(p) for p in p_map(ei_n0, 1)]
    outputs = [None] * len(channels)

    for c in range(len(channels)):
        outputs[c] = channels[c].add_noise(np.array(codes))

    return outputs
    def _retrieveComponent(self, instance, componentName):
        from Channel import Channel
        channel = Channel(componentName)

        import pyre.parsing.locators
        locator = pyre.parsing.locators.builtIn()

        return channel, locator
Exemple #26
0
    def __init__(self):
        # set the name
        self.name_ = "CombinerNode"
        self.label_ = ""

        # initial status
        self.status_ = Node.NotReady_

        # buffer
        self.buffer_ = None

        # Provide an input and output data channel
        self.out_channels_ = [Channel("output", self)]
        self.in_channels_ = [Channel("input", self)]

        # Linked splitter node
        self.sp_node_ = None
    def run(self):
        self.log("Starting")
        self.chanlist.exitThread = False
        self.chanlist.readConfig()
        self.chanlist.sleepTime = 0.1

        if self.myOverlay == None:
            self.log("Overlay not defined. Exiting.")
            return

        self.chanlist.myOverlay = self.myOverlay
        self.fullUpdating = (self.myOverlay.backgroundUpdating == 0)
        validchannels = 0

        for i in range(self.myOverlay.maxChannels):
            self.chanlist.channels.append(Channel())

            if self.myOverlay.channels[i].isValid:
                validchannels += 1

        # Don't load invalid channels if minimum threading mode is on
        if self.fullUpdating and self.myOverlay.isMaster:
            if validchannels < self.chanlist.enteredChannelCount:
                DebugNotify("Background Loading...")

            for i in range(self.myOverlay.maxChannels):
                if self.myOverlay.channels[i].isValid == False:
                    while True:
                        if self.myOverlay.isExiting:
                            self.log("Closing thread")
                            return
                        time.sleep(2)

                        if self.paused == False:
                            break

                    self.chanlist.channels[i].setAccessTime(
                        self.myOverlay.channels[i].lastAccessTime)

                    try:
                        if self.chanlist.setupChannel(i + 1, True, True,
                                                      False) == True:
                            while self.paused:
                                if self.myOverlay.isExiting:
                                    self.log("IsExiting")
                                    return
                                time.sleep(2)

                            self.myOverlay.channels[
                                i] = self.chanlist.channels[i]
                            if self.myOverlay.channels[i].isValid == True:
                                OptNotify("Channel " + str(i + 1) + " Added",
                                          icon=self.myOverlay.getChlogo(i + 1))
                    except Exception, e:
                        self.log("Unknown Channel Creation Exception",
                                 xbmc.LOGERROR)
                        self.log(traceback.format_exc(), xbmc.LOGERROR)
                        return
Exemple #28
0
    def channels_list_by_id(self, youtube):
        channels_response = youtube.channels().list(mine=True,
                                                    part="snippet").execute()

        Channels = []
        for item in channels_response["items"]:
            Channels.append(Channel(item["id"], item["snippet"]["title"],
                                    None))
        return Channels
Exemple #29
0
    def __init__(self, application):
        QtGui.QMainWindow.__init__(self)

        self.channel = Channel()
        self.channel.open()

        self.application = application
        self.setWindowTitle(u'Контроллер')

        central_widget = QtGui.QWidget()
        self.main_vsplitter = MainVSplitter(self, central_widget)
        self.setCentralWidget(central_widget)

        self.connect(application, QtCore.SIGNAL('aboutToQuit()'), self.on_quit)

        self.statusBar().showMessage(u'Готов')

        self.resize(800, 600)
Exemple #30
0
    def __init__(self, ip):
        self.readData = builder.boolOut('readData',
                                        on_update=self.place_voltages,
                                        HIGH=0.1)
        self.on = builder.boolOut('on', on_update=self.turnOn, HIGH=0.1)
        self.off = builder.boolOut('off', on_update=self.turnOff, HIGH=0.1)
        self.avrgVolt = builder.aIn('avrgVolt')
        self.avrgTemp = builder.longIn('avrgTemp')
        self.avrgVoltInner = builder.aIn('avrgVoltInner')
        self.avrgVoltOuter = builder.aIn('avrgVoltOuter')
        self.marker = builder.longIn('marker')
        self.setVoltInner_pv = builder.aOut("setVoltInner",
                                            on_update=self.setVoltInner)
        self.setVoltOuter_pv = builder.aOut("setVoltOuter",
                                            on_update=self.setVoltOuter)
        self.write_voltages_pv = builder.boolOut("write_voltages",
                                                 on_update=self.write_voltages,
                                                 HIGH=0.1)
        self.datacsv = "data.csv"
        self.reset = builder.boolOut("reset", on_update=self.Reset, HIGH=0.1)
        self.adj_current_pv = builder.boolOut("adj_current",
                                              on_update=self.adj_current,
                                              HIGH=0.1)
        self.adj_msg = "Last done: "
        self.adj_stat_pv = builder.stringIn("adj_stat",
                                            initial_value=self.adj_msg +
                                            "none")

        self.chlist = []
        self.wboard, self.wch = 0, 0
        self.ip = ip
        self.dictWiener, self.dictTPC = {}, {}

        #snmp 5.8 for user defined precision in current readings, compiled according to
        # http://file.wiener-d.com/software/net-snmp/net-snmp-CompileForExtendedPrecision-2015-03-06.txt
        self.snmpwalk = "/usr/local/Net-SNMP_5-8/code/apps/snmpwalk"
        self.snmpset = "/usr/local/Net-SNMP_5-8/code/apps/snmpset -v 2c -c seCrET " + self.ip + " WIENER-CRATE-MIB::"

        file = open("file.txt", "w")
        file.write(
            "TPC sector \t TPC channel \t WIENER board \t WIENER channel \n")
        for self.i in xrange(1, 25):  # sector
            for self.j in xrange(2):  # channel
                a = '{0} \t\t {1} \t\t {2} \t\t {3} \n'.format(
                    self.i, self.j, self.wboard, self.wch)
                file.write(a)
                self.chlist.append(
                    Channel(self.i, self.j, self.wboard, self.wch,
                            self.snmpset))
                self.dictWiener[(self.wboard, self.wch)] = self.chlist[-1]
                self.dictTPC[(self.i, self.j)] = self.chlist[-1]
                self.wch += 1
                if (self.wch > 15):
                    self.wboard += 1
                    self.wch = 0
        file.close()
        print "Before start, you have to Load Voltage from file through Load Voltage button "
	def __init__(self, parent):
		Channel.__init__(self)
		self.parent = parent
		self.queue = []
		self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
		self.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
		self.set_reuse_addr()
		self.dest = ('255.255.255.255', 10314)
		self.connect(self.dest)
		# elapsed time
		self.last = 0
		
		# what IP address the server is listening on
		if len(sys.argv) == 2:
			self.addr = sys.argv[1]
		else:
			self.addr = getIP()
		print "LANParty Listening on", self.addr
		print "(You can specify this with an argument)"
Exemple #32
0
    def __init__(self, parent):
        Channel.__init__(self)
        self.parent = parent
        self.queue = []
        self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
        self.set_reuse_addr()
        self.dest = ('255.255.255.255', 10314)
        self.connect(self.dest)
        # elapsed time
        self.last = 0

        # what IP address the server is listening on
        if len(sys.argv) == 2:
            self.addr = sys.argv[1]
        else:
            self.addr = getIP()
        print "LANParty Listening on", self.addr
        print "(You can specify this with an argument)"
Exemple #33
0
 def Pump(self):
     # don't send anything if there's been a socket error
     # broadcast the server IP address every two seconds
     if self.last < time() - 2:
         #print 'broadcasting ip...'
         self.Send(["ip", self.addr])
         self.last = time()
     # if we have UDP messages queued, then send them too
     while self.queue:
         self.Send(self.queue.pop(-1))
     Channel.Pump(self)
Exemple #34
0
def main():
    connect = subprocess.Popen(['python', 'child.py'],
                               stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE)
    ch = Channel(connect.stdin, connect.stdout)
    ch.send('hello World')
    print ch.recv()
Exemple #35
0
class MainWindow (QtGui.QMainWindow):

	def __init__ (self, application):
		QtGui.QMainWindow.__init__ (self)
		
		self.channel = Channel ()
		self.channel.open ()

		self.application = application
		self.setWindowTitle (u'Контроллер')

		central_widget = QtGui.QWidget ()
		self.main_vsplitter = MainVSplitter (self, central_widget)
		self.setCentralWidget (central_widget)

		self.connect (application, QtCore.SIGNAL ('aboutToQuit()'), self.on_quit)

		self.statusBar ().showMessage (u'Готов')

		self.resize (800, 600)

	def on_quit (self):
		self.channel.close ()
		
def test_verifyBind():
    c = Channel(apiKey, secretKey)
    optional = dict()
    optional[Channel.DEVICE_TYPE] = Channel.DEVICE_ANDRIOD;
    ret = c.verifyBind(user_id, optional)
    print ret
	def __init__(self, *args, **kwargs):
		Channel.__init__(self, *args, **kwargs)
		# initiate connection back to the client
		self.id = self._server.MakeNewID(self)
		#print "MAKE NEW ID:", self.id
		self.outgoing = PdSender(self)
Exemple #38
0
def main():
	connect = subprocess.Popen(['python','child.py'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
	ch = Channel(connect.stdin,connect.stdout)
	ch.send('hello World')
	print ch.recv()
def test_fetchMessage():
    c = Channel(apiKey, secretKey)
    ret = c.fetchMessage(user_id)
    print ret
def test_deleteMessage():
    c = Channel(apiKey, secretKey)
    msg_id = "111"
    ret = c.deleteMessage(user_id, msg_id)
    print ret
	def __init__(self):
		listen = ("0.0.0.0", 10316)
		Channel.__init__(self)
		self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
		self.bind(listen)
		self.incoming = []
def test_pushMessage_to_all():
    c = Channel(apiKey, secretKey)
    push_type = Channel.PUSH_TO_ALL
    optional = dict()
    ret = c.pushMessage(push_type, message, message_key, optional)
    print ret
def test_fetchTag():
    c = Channel(apiKey, secretKey)
    ret = c.fetchTag()
    print ret
Exemple #44
0
from Channel import Channel

c = Channel("HerraMustikka")
for f in c.get_followers():
    print(f["user"]["name"])
    # if f['user']['name'] == 'varesa':
    #    print("Found!")
def test_deleteTag():
    c = Channel(apiKey, secretKey)
    optional = dict()
    optional[Channel.USER_ID] = user_id
    ret = c.deleteTag(tagname, optional)
    print ret
def test_queryUserTag():
    c = Channel(apiKey, secretKey)
    ret = c.queryUserTag(user_id)
    print ret
def test_queryDeviceType():
    c = Channel(apiKey, secretKey)
    ret = c.queryDeviceType(channel_id)
    print ret
 def __init__(self , parent):
     self.mouse_pressed = False
     Channel.__init__(self, parent)
     self.layout.setContentsMargins(6,2,6,2)
def test_queryBindList():
    c = Channel(apiKey, secretKey)
    optional = dict()
    optional[Channel.CHANNEL_ID] = channel_id
    ret = c.queryBindList(user_id, optional)
    print ret
	def messagePlayer(self, user, message):
		channel = Channel()
		channel.sendMessage(user, self.game, message)
 def __init__(self , parent):
     self.automatically_muted = False
     self.extended_panel = None
     Channel.__init__(self, parent)
     self.setContentsMargins(0,0,0,0)
	def messageAll(self, message):
		channel = Channel()
		channel.sendMessageToAll(self.game, message)
Exemple #53
0
    def initializeChannel(self):
	from Channel import Channel
	channel = Channel()
	self.setChannel(channel)
	channel.setMyAgent(self)
	return(channel)
Exemple #54
0
	def __init__(self, root, name):

		Channel.__init__(self, root, name)
		self.__init__Battle__(root, name)
	def __init__(self, parent, *args, **kwargs):
		Channel.__init__(self, *args, **kwargs)
		self.parent = parent
		self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
		self.connect((self.parent.addr[0], 10315))
 def __init__(self , parent):
     Channel.__init__(self, parent)