예제 #1
0
파일: records.py 프로젝트: rayman18/wydev
	def __do_rename(kbd):
		if kbd.text:
			record_id = context['selected'].record.id
			scheduler = WyRecord().scheduler
			scheduler.UpdateRecordingName(record_id, kbd.text)
			context['selected'].show_menu()
			kbd.hide()
		return None
예제 #2
0
파일: wymodcp.py 프로젝트: rayman18/wydev
    def record_universe(self, command):
        # Initiate WyRecord scheduler
        try:
            Scheduler = WyRecord().scheduler
        except:
            self.wymodcp_conn.send('ERROR SCHEDULER')
            return 0

        # GETLIST Command -> 'universe:RECORD command:GETLIST arg1:nFlags arg2:ignore_periodic'
        # - arg1 (flag) can be RECORDING_FLAG_RUNNING = 1, RECORDING_FLAG_COMPLETED = 2, RECORDING_FLAG_INCONFLICT = 4,
        # RECORDING_FLAG_SCHEDULED = 8, RECORDING_FLAG_CANCELED = 16, RECORDING_FLAG_MISSED = 16, RECORDING_FLAG_ALL = 255
        # - arg2 (ignore_periodic) can be True or False
        # Return value: Recording list or 'ERROR'
        if 'GETLIST' in command['command']:
            try:
                result = []
                rec_list = Scheduler.GetRecordingList(
                    nFlags=int(command['arg1']),
                    ignore_periodic=self.str2bool(command['arg2']))
                for e in rec_list:
                    result.append(str(e))
            except:
                result = 'ERROR'

        # GETPERIODICLIST Command -> 'universe:RECORD command:GETPERIODICLIST arg1:active arg2:unactive'
        # - arg1 (active) can be True or False
        # - arg1 (unactive) can be True or False
        # Return value: Periodic recording list or 'ERROR'
        elif 'GETPERIODICLIST' in command['command']:
            try:
                result = []
                rec_list = Scheduler.GetPeriodicRecordingList(
                    active=self.str2bool(command['arg1']),
                    unactive=self.str2bool(command['arg2']))
                for e in rec_list:
                    result.append(str(e))
            except:
                result = 'ERROR'

        # SAVELIST Command -> 'universe:RECORD command:SAVELIST'
        # Return value: OK or 'ERROR'
        elif 'SAVELIST' in command['command']:
            try:
                print "Saving Recording List"
                Scheduler.SaveRecordingList()
                result = 'OK'
            except:
                result = 'ERROR'

        # RENAME Command -> 'universe:RECORD command:RENAME arg1:nRecordingID arg2:new_name'
        # - arg1 (nRecordingID) must be a valid record id taken from records list
        # - arg2 (new_name) must be the new name of the record
        # Return value: OK or 'ERROR'
        elif 'RENAME' in command['command']:
            try:
                print 'Renaming record id %d to %s' % (command['arg1'],
                                                       command['arg2'])
                res = Scheduler.UpdateRecordingName(nRecordingID=int(
                    command['arg1']),
                                                    new_name=command['arg2'])
                if res is None:
                    result = 'OK'
                else:
                    result = 'ERROR'
            except:
                result = 'ERROR'

        # STOP Command -> 'universe:RECORD command:STOP arg1:nRecordingID arg2:stop_at_player_pos'
        # - arg1 (nRecordingID) must be a valid record id taken from records list
        # - arg2 (stop_at_player_pos) can be True or False (always False it seems ???)
        # Return value: OK or 'ERROR'
        elif 'STOP' in command['command']:
            try:
                print "Stopping all running records"
                res = Scheduler.StopRecording(
                    nRecordingID=int(command['arg1']),
                    stop_at_player_pos=self.str2bool(command['arg2']))
                if res == True:
                    result = 'OK'
                else:
                    result = 'ERROR'
            except:
                result = 'ERROR'

        # STOPALL Command -> 'universe:RECORD command:STOPALL'
        # Return value: OK or 'ERROR'
        elif 'STOPALL' in command['command']:
            try:
                print "Stopping all running records"
                Scheduler.StopAllRunningRecord()
                result = 'OK'
            except:
                result = 'ERROR'

        # CHECKSCHEDULE Command -> 'universe:RECORD command:CHECKSCHEDULE arg1:save_list'
        # - arg1 (save_list) can be True or False
        # Return value: OK or 'ERROR'
        elif 'CHECKSCHEDULE' in command['command']:
            try:
                print 'Checking scheduled records'
                res = Scheduler.CheckSchedule(
                    save_list=self.str2bool(command['arg1']))
                if res is None:
                    result = 'OK'
                else:
                    result = 'ERROR'
            except:
                result = 'ERROR'

        # STARTLIVE Command -> 'universe:RECORD command:STARTLIVE arg1:nServiceID arg2:nForcedDeviceID arg3:duration arg4:name'
        # - arg1 (nServiceID)
        # - arg2 (nForcedDeviceID)
        # - arg3 (duration)
        # - arg4 (name)
        # Return value: OK or 'ERROR'
        elif 'STARTLIVE' in command['command']:
            try:
                print 'Starting live record'
                res = Scheduler.StartLiveRecording(
                    nServiceID=int(command['arg1']),
                    nForcedDeviceID=self.str2bool(command['arg2']),
                    duration=int(command['arg3']),
                    name=command['arg4'])
                if res['status'] != error.WYRECORD_SUCCESS:
                    result = 'OK'
                else:
                    result = 'ERROR'
            except:
                result = 'ERROR'

        # UNKNOW RECORD COMMAND
        else:
            print 'UNKNOW RECORD COMMAND !!!'
            result = 'ERROR COMMAND'

        # Send result through socket
        self.wymodcp_conn.send(str(result))