示例#1
0
def load_config(config_path):
    '''
    Load up configuration settings
    '''
    parser = SafeConfigParser(DEFAULTS)

    converters = {
        'min_interval': parser.getint,
        'max_errors': parser.getint,
        'max_history': parser.getint,
        'timeout': parser.getint,
        'processes': parser.getint,
    }

    if os.path.exists(config_path):
        parser.read(config_path)
    else:
        raise RuntimeError('Could not find configuration file %s' %
                           config_path)

    config = Struct()

    for section in parser.sections():
        d = {
            k: converters[k](section, k) if k in converters else v
            for k, v in parser.items(section)
        }
        config[section] = Struct(d)

    return config
示例#2
0
 def __init__(self, parent):
     RectBox.__init__(self, parent)
     self.reInitBuffer = True
     self.cache.down.tabIdx = None
     self.cache.drag.tabIdx = None
     self.cache.down.closeIdx = None
     self.cache.drag.closeIdx = None
     self.cache.tabIdx = None
     self.cache.skip = Struct(leftDClick=False)
     self.tab_num_limit = 20
     self.tab_width = 200
     self.tab_height = 26
     self.bottom_height = 1
     self.tab_rel_width = 200
     self.scrollbar_size = 6
     self.TextEdit = None
     self.text_edit_tabIdx = None
     self.rects = ((0, 0, 0, 0))
     self.FileDrop = ListBoxTabDnD(self)
     self.SetDropTarget(self.FileDrop)
     # self.SliderV = ListBoxTabSliderV(self)
     self.bmp = Struct()
     # self.bmp.add = images.listbox_tab_add.GetBitmap()
     self.bmp.close = images.listbox_tab_close.GetBitmap()
     color = self.parent.st.BG_COLOR
     self.SetBackgroundColour(color)
     self.InitBuffer()
示例#3
0
 def __init__(self, parent):
     threading.Thread.__init__(self)
     self.parent = parent
     self.loop = True
     self.hStream = 0
     self.interval = 0.005
     self.fadein = Struct(cnt=0.0, time=0.0)
     self.fadeout = Struct(cnt=0.0, time=0.0)
     self.path = self.parent.cue.path
     self.pending = False
     self.resume = None
     # self._Thread__exc_clear()
     self.start()
示例#4
0
 def __init__(self, parent):
     RectBox.__init__(self, parent)
     self.parent = parent
     self.height = 23
     self.buffer.fps = 30
     self.font_colors = []
     self.button_colors = []
     self.LoadBitmapImages()
     self.font_color_on = (0, 0, 0)
     self.font_color_off = (125, 125, 125)
     self.button_color_on = (200, 200, 220)
     self.button_color_toggle_on = (255, 120, 120)
     self.button_color_off = (0, 0, 0)
     self.button_color_down = (180, 180, 180)
     self.polygons = Struct(play=None, next=None, prev=None)
     self.downed_button = None
     self.button_flash = [0.0, 0.0, 0.0, 0.0, 0.0]
     self.button_status = [False, False, False, False, False]
     self.toggle_buttons = [True, False, True, False, True]
     # self.button_flash = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     # self.button_status = [False, False, False, False, False, False]
     # self.toggle_buttons = [True, False, True, False, True, True]
     self.SetBackgroundColour((35, 35, 35))
     self.SetPreInitRects()
     self.SetButtonColors()
     self.OnSize()
     self.InitBuffer()
示例#5
0
 def __init__(self, parent):
     RectBox.__init__(self, parent)
     self.reInitBuffer = True
     self.bmp = Struct()
     self.bmp.add = images.listbox_tab_add.GetBitmap()
     color = self.parent.st.HEADER_BG_COLOR
     self.SetBackgroundColour(color)
     self.InitBuffer()
示例#6
0
    def __init__(self, parent):
        RectBox.__init__(self, parent)
        self.parent = parent

        self.pending = Struct(drag_vpy=None)
        color = self.parent.st.SCROLLBAR_BG_COLOR
        self.SetBackgroundColour(color)
        self.reInitBuffer = True
        self.InitBuffer()
示例#7
0
 def LoadBitmapImages(self):
     self.bmp = Struct()
     command = 'self.bmp.%s_%s = images.playbox_button_%s_%s.GetBitmap()'
     for nv in ('ff', 'fr'):
         for cv in ('black', 'white'):
             exec(command % (nv, cv, nv, cv))
     for nv in ('highlight', 'play', 'loop'):
         for cv in ('red', 'black', 'white'):
             exec(command % (nv, cv, nv, cv))
示例#8
0
    def DrawSliderV(self, dc):
        width, height = self.GetSize()
        slider = wx.Rect(0, 0, width, height)
        btnup = wx.Rect(0, 0, width, width)
        btndown = wx.Rect(0, height - width, width, width)
        slidable = wx.Rect(0, width, width, height - width * 2)
        # print(slidable)
        # _, y, _, h = self.parent.TabList.rects[-1]
        # length = y + h
        length = self.parent.GetItemsLength() * self.parent.GetRowsHeight()
        # list_height = self.parent.TabList.GetSize().height
        if length <= 0 or height <= 0:
            return
        shownRatio = height / length
        if shownRatio > 1.0:
            shownRatio = 1.0

        # y = self.parent.rects[0][3]
        # x = parenst_size.width - width
        # self.SetRect((x, y, width, parenst_size.height - y))

        # if length != 0:
        #     shownRatio = 1.0 * self.parent.List.GetSize().height / length
        # else:
        #     shownRatio = 1.0
        # if shownRatio > 1.0:
        #     shownRatio = 1.0
        h = slidable.height * shownRatio
        if h < width:
            h = 1.0 * width
        # div = list_height - 10
        div = length - self.parent.TabList.GetSize().height
        if div != 0:
            posCYRatio = 1.0 * (-self.parent.GetVirtualPositionY()) / div
            # posCYRatio = 1.0
        else:
            posCYRatio = 1.0
        if posCYRatio > 1.0:
            posCYRatio = 1.0
        #     self.parent.parent.innerList[self.parent.selectedList].rects.offset.y = -div
        # x = slidable.x
        y = slidable.y + math.ceil((slidable.height - h) * posCYRatio)
        knob = wx.Rect(0, y, width, h)
        self.rects = Struct(slider=slider, slidable=slidable,
                            knob=knob, btnup=btnup, btndown=btndown)

        bgcolor = self.parent.st.SCROLLBAR_BG_COLOR
        fgcolor = self.parent.st.SCROLLBAR_FG_COLOR
        bdcolor = self.parent.st.SCROLLBAR_PN_COLOR
        dc.DrawRectangleList((slidable,),
                             pens=wx.Pen(bgcolor, 1), brushes=wx.Brush(bgcolor))
        lines = ((slidable.x + 1, slidable.y, slidable.x + width - 1, slidable.y),
                 (slidable.x + 1, slidable.height + width - 1, slidable.x + width - 1, slidable.height + width - 1))
        dc.DrawLineList(lines, pens=wx.Pen(bgcolor, 1))
        dc.DrawRectangleList((knob, btnup, btndown),
                             pens=wx.Pen(bdcolor, 1), brushes=wx.Brush(fgcolor))
示例#9
0
 def InitControlEvent(self):
     self.reInitWave = True
     self.waveform_length = 1500
     self.pending = Struct(dbresp=False, mfeats=False, mdx=False)
     self.waveform_init = numpy.linspace(0, 0, self.waveform_length)
     self.cue = Struct(
         mdx=None,
         path=None,
         waveform=None,
         is_playing=False,
         hStream=0,
         tempo=0.0,
         key='-',
         offset=0,
         finish=0,
         duration=0.0,
         position=0.0,
         resume=0,
         fffrTime=15,
         fffr_variable=15.0,
         fffr_static=15,
         channel=2,
         loop_on=False,
         autogain_on=False,
         autogain=0.4,
         volume=1.0,
         auto_next=True,
         highlight_on=False,
         highlight_skip=False,
         highlight_offset=None,
         highlight_variable=None,
         highlight_static=32,
         order=None,
         listId=None,
         item=None,
         agc_headroom=1.0,
     )
     self.item_column = ListBoxColumn()
     self.last_control_time = time.time()
示例#10
0
 def watch_new_proclist(self):
     if self.Messenger.has_message() is False:
         return
     message, address = self.Messenger.pop_message()
     # print message
     if message == 'terminate':
         self.terminate()
     elif message == 'connected':
         self.Messenger.send_message('connected', 'macrobox_mfeats')
         # self.Messenger.send_message('connected', CLIENT_ADDRESS)
     elif message == 'master_alive':
         pass
     elif message not in [v.path for v in self.proclist]:
         self.proclist.append(
             Struct(path=message, proc=Thread(message), address=address))
         self.proclist[-1].daemon = True
         self.proclist[-1].proc.start()
示例#11
0
def di_bfoot2(vec):
    return Vector2(1, 0)

def i_bfoot3(vec):
    return -vec.y

def di_bfoot3(vec):
    return Vector2(0, -1)

def i_bfoot4(vec):
    return vec.y - 30

def di_bfoot4(vec):
    return Vector2(0, 1)

bf_suite1                      = Struct()
bf_suite1.target_cb            = TargetBygfoot
bf_suite1.d_target_cb          = DerTargetBygfoot
bf_suite1.constraints_eq_l     = []
bf_suite1.d_constraints_eq_l   = []
bf_suite1.constraints_ineq_l   = [i_bfoot1, i_bfoot2, i_bfoot3, i_bfoot4]
bf_suite1.d_constraints_ineq_l = [di_bfoot1, di_bfoot2, di_bfoot3, di_bfoot4]
bf_suite1.start_point          = Vector2(50000, 100)


suite1                      = Struct()
suite1.target_cb            = Target1
suite1.d_target_cb          = DerTarget1
suite1.constraints_eq_l     = [e11]
suite1.d_constraints_eq_l   = [de11]
suite1.constraints_ineq_l   = []