コード例 #1
0
    def merge_voices_to_chords(self):
        """Fügt Töne mit gleicher Länge, gleichem Offset und ohne Haltebogen zu einem Akkord zusammen"""

        unique_offsets_with_sustains = self.get_unique_offsets_with_sustains()

        for sustain, offset in unique_offsets_with_sustains:
            possible_chord = []
            for ind_voice, voice1 in enumerate(self.voices):
                for ind_note, note1 in enumerate(voice1.notes_chords_rests):
                    if self.previous_measure is None and note1.sustain == sustain and note1.offset == offset and note1.tie == '' and isinstance(
                            note1, note.Note):
                        possible_chord.append(note1)
                        if len(possible_chord) == 1:
                            swap_index = (ind_voice, ind_note)
                        elif len(possible_chord) > 1:
                            voice1.notes_chords_rests[ind_note] = rest.Rest(
                                sustain)
                    elif note1.sustain == sustain and note1.offset == offset and note1.tie == '' and isinstance(
                            note1, note.Note) and not (
                                ind_note == 0
                                and self.previous_measure.voices[ind_voice].
                                notes_chords_rests[-1].tie == 'start'):
                        possible_chord.append(note1)
                        if len(possible_chord) == 1:
                            swap_index = (ind_voice, ind_note)
                        elif len(possible_chord) > 1:
                            voice1.notes_chords_rests[ind_note] = rest.Rest(
                                sustain)
            if len(possible_chord) > 1:
                merged_chord = chord.Chord(possible_chord, sustain)
                self.voices[swap_index[0]].notes_chords_rests[
                    swap_index[1]] = merged_chord
コード例 #2
0
def voices_generator(measure1, measure_length, tied_tones):

    cons_pause_threshold = 0.07
    cons_note_threshold = 0.01
    notes = ((1, 0.01, 0.07), (2, 0.07, 0.13), (3, 0.13, 0.19),
             (4, 0.19, 0.26), (6, 0.26, 0.39), (8, 0.39, 0.52),
             (10, 0.52, 0.64), (12, 0.64, 0.77), (14, 0.77, 0.88), (16, 0.88,
                                                                    1.00))
    rests = ((1, 0.07, 0.012), (2, 0.012, 0.18), (3, 0.18, 0.24),
             (4, 0.24, 0.31), (6, 0.31, 0.44), (8, 0.44, 0.57),
             (10, 0.57, 0.69), (12, 0.69, 0.82), (14, 0.82, 0.93), (16, 0.93,
                                                                    1.00))
    log = open('log1.txt', 'a')

    for voice1 in measure1:
        voice_object = voice.Voice()
        for tone in voice1:
            temp = (float(tone[1]) / float(measure_length))  # (Prozentwert)
            if temp > cons_pause_threshold and tone[0] == 'X':
                log.write('z: ' + str(temp) + '\n')
                for value, min_v, max_v in rests:
                    if min_v < temp <= max_v:
                        rest_object = rest.Rest(value)
                        voice_object.add(rest_object)

            elif temp > cons_note_threshold and not tone[0] == 'X':
                log.write(tone[0] + ': ' + str(temp) + '\n')
                for value, min_v, max_v in notes:
                    if min_v < temp <= max_v:
                        note_object = note.Note(tone[0], value)
                        voice_object.add(note_object)

        log.write(
            str(measure_length) + '---------------------voice-------------\n')

        for tone in tied_tones:
            if tone == voice_object.notes_chords_rests[-1].str_format:
                voice_object.notes_chords_rests[-1].tie = 'start'

        voice_object.improve_rhythm()

        yield voice_object

    log.write('---------------------measure-------------\n')
    log.close()
コード例 #3
0
#
# Test script for router function.
#

import sys
import datetime
import libxml2

sys.path.append("..")
import rest

from nsx_basic_input import *
from case23_nsx_router_delete_input import *

caseName = 'case23_nsx_router_delete'
restclient = rest.Rest(NSX_IP, NSX_USER, NSX_PWD, True)


def deleteRouter():
    respData = restclient.delete(NSX_URL + '/api/4.0/edges/' + NSX_ROUTER_ID,
                                 'deleteRouter')
    output(restclient.getDebugInfo() + restclient.prettyPrint(respData))


def output(msg):
    f = file(
        datetime.datetime.now().strftime("../log/" + caseName +
                                         "_output_20%y%m%d%H%M%S.log"), "w")
    f.write(msg)
    f.close()
コード例 #4
0
        pattern_error = re.compile("(?P<month>(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?P<day> ?[1-9]?[0-9]).*(?P<error>\[err\]).*)")
        
        i=0
        test_cases= []
        for line in lines:
            test_cases.append(TestCase(line, '', '','', ''))
            if pattern_emerg.findall(line):
                test_cases[i].add_error_info('Emerg: ' +args.baseURL )
            elif pattern_error.findall(line):
                test_cases[i].add_skipped_info('Error: ' +args.baseURL)
            i+=1
        ts = [TestSuite("InfoLog", test_cases)]
        print(TestSuite.to_xml_string(ts))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    
    #--baseURL=http://{BLGW_IP}/
    parser.add_argument('--baseURL', help ="BLGW IP")
    
    parser.add_argument('unittest_args', nargs='*')
    
    args = parser.parse_args()
    
    restLog = rest.Rest(args.baseURL +'a/read/serviceErrorHistory')
    
    # Now set the sys.argv to the unittest_args (leaving sys.argv[0] alone)
    sys.argv[1:] = args.unittest_args
    unittest.main()
コード例 #5
0
# Test script for identity function.
# 用户处于已认证状态时,可以正常调用API;而已经注销的用户,则不能成功调用API;默认情况下用户处于已认证状态,调用API操作全程由HTTPS加密
# 


import sys
import datetime
import libxml2

sys.path.append("..")
import rest

from nsx_basic_input import *

caseName = 'case01_nsx_identity_login'
restclient = rest.Rest(NSX_IP, VC_USER, VC_PWD, True)


def userLogin():
    respData = restclient.put('%s/api/2.0/services/usermgmt/user/%s/enablestate/1'%(NSX_URL, NSX_USER),
        '', 'userLogin')
    output(restclient.getDebugInfo() + restclient.prettyPrint(respData))


def output(msg):
    f = file(datetime.datetime.now().strftime("../log/" + caseName + "_output_20%y%m%d%H%M%S.log"), "w")
    f.write(msg)
    f.close()	


def main():
コード例 #6
0
    def __init__(self, house, clock, schedule):

        # this allows the Person to be aware of the time
        self.clock = clock

        # a unique identification number for the Person
        self.id = -1

        # the home
        self.home = house

        # the biology characteristics
        self.bio = bio.Bio()

        # the Age of the person
        self.bio.age = 30

        # The gender of a person
        self.bio.gender = bio.FEMALE

        # set the social characteristics
        self.socio = social.Social(self.bio.age)

        # set the location of the Person to a copy of the Home's location
        self.location = loc.Location(house.location.geo, house.location.local)

        # the number of steps
        num_sample_points = len(self.clock.hist_time)

        # create major need-associations (income, rest, hunger)
        self.income = income.Income(clock, num_sample_points)
        self.rest = rest.Rest(clock, num_sample_points)
        self.hunger = hunger.Hunger(clock, num_sample_points)

        # create minor need-associations (travel, interruption)
        self.travel = travel.Travel(clock, num_sample_points)
        self.interruption = interruption.Interruption(clock, num_sample_points)

        # a dictionary (key, value)-pairs of need-associations
        self.needs = {
            need.INCOME: self.income,
            need.REST: self.rest,
            need.HUNGER: self.hunger,
            need.TRAVEL: self.travel,
            need.INTERRUPTION: self.interruption,
        }

        # the state of a person
        self.state = state.State(state.IDLE)

        # history of the Person's state, activities, and location
        self.hist_state = state.IDLE * np.ones((num_sample_points, 1))
        self.hist_activity = activity.NO_ACTIVITY * np.ones(
            self.hist_state.shape)
        self.hist_local = loc.HOME * np.ones(self.hist_state.shape)

        # history of magnitude of each need. There must to be one per person
        self.H = -1 * np.ones((num_sample_points, need.N))
        self.need_vector = -1 * np.ones((need.N, 1))
        self.schedule = schedule

        return
コード例 #7
0
 def __init__(self):
     self.api = rest.Rest(REST_EPR)
     self.api.key = APIKEY
     pass
コード例 #8
0
import serial_shell
import rest

print('# Testing NameServers')

# Open a serial connection to the unit under test
con = serial_shell.Shell('COM7')

# Get the list of nameservers (ignore the prompt status)
_status, output = con.execute('cat /etc/resolv.conf | grep nameserver')
# Parse the output from the shell
ns = output[0][11:].strip().split(' ')

# Open a connection to the Redfish server
red = rest.Rest('https://10.207.15.119', 'admin', 'admin')

# Get the list of nameservers
json = red.get('/redfish/v1/Managers/1/EthernetInterfaces/enp2s0')
ns_red = json['NameServers']

# Compare the actual list with what Redfish says
if ns != ns_red:
    raise Exception('Redfish does not match the system:' + str(ns_red) + ':' +
                    str(ns) + ':')
print('OK Redfish list of servers matches the system config file.')

# Change the list of nameservers
print('Changing the list of NameServers to [1.2.3.4]')
red.patch('/redfish/v1/Managers/1/EthernetInterfaces/enp2s0',
          {'NameServers': ['1.2.3.4']})