def get_receive_errors(rev_old, rev_new, file_type, function):
  checkable = True
  if file_type == "js":
    checkable = config.getboolean("receive", "CHECK_JAVASCRIPT")
  elif file_type == "php":
    checkable = config.getboolean("receive", "CHECK_PHP")

  if not checkable:
    return None

  files = _get_receive_files(rev_old, rev_new, file_type)
  if not files:
    return None

  tmp_dir = config.get("receive", "TMP_DIR")
  errors = []
  for file_path in files:
    mkdir("-p", "/".join((tmp_dir + file_path).split("/")[:-1]))
    system("git show %s:%s > %s" % (rev_new, file_path, tmp_dir + file_path))
    if path.exists(tmp_dir + file_path):
      file_error = function(tmp_dir + file_path)
      if file_error:
        errors.append(file_path + file_error)

  rm("-rf", tmp_dir)
  return "\n".join(errors)
 def __init__(self):
     super(HotKeySetting, self).__init__()
     self.main_table = gtk.Table(12, 2)        
     self.main_table.set_row_spacings(CONTENT_ROW_SPACING)
     self.pack_start(self.main_table, False, True)
     self.create_hotkey_box()
     
     self.control_entrys = [
         self.toggle_window_entry,
         self.toggle_lyrics_status_entry,
         self.toggle_lyrics_lock_entry,
         self.playpause_entry,
         self.previous_entry,
         self.next_entry,
         self.increase_vol_entry,
         self.decrease_vol_entry]
     
     self.using_check_button.connect("toggled", self.change_enbale_status)
     self.using_check_button.set_active(config.getboolean("globalkey", "enable"))        
     self.toggle_window_entry.connect("shortcut-key-change", self.change_toggle_window_key)
     self.toggle_lyrics_status_entry.connect("shortcut-key-change", self.change_lyrics_status_key)
     self.toggle_lyrics_lock_entry.connect("shortcut-key-change", self.change_lyrics_lock_key)
     self.playpause_entry.connect("shortcut-key-change", self.change_playpause_key)
     self.previous_entry.connect("shortcut-key-change", self.change_previous_key)
     self.next_entry.connect("shortcut-key-change", self.change_next_key)
     self.increase_vol_entry.connect("shortcut-key-change", self.change_increase_vol_key)
     self.decrease_vol_entry.connect("shortcut-key-change", self.change_decrease_vol_key)
     
     # for each_entry in self.control_entrys:
     #     each_entry.connect("wait-key-input", lambda w, d: self.pause_global_keys())
     
     if not config.getboolean("globalkey", "enable"):
         for each_entry in self.control_entrys:
             each_entry.set_sensitive(False)
 def load(self):
     '''load configure'''
     if not self.__need_load_prefs:
         return
     
     # get uri
     uri = config.get("player", "uri")
     
     # get seek
     seek = int(config.get("player", "seek"))
     
     # get state 
     state = config.get("player", "state")
     
     # Init player state
     play = False
     self.logdebug("player load %s in state %s at %d", uri, state, seek)
     if config.getboolean("player", "play_on_startup") and state == "playing":
         play = True
         
     # load uri
     if uri:    
         song = MediaDB.get_song(uri)
         if song and song.exists():
             if not config.getboolean("player", "resume_last_progress") or not play:
                 seek = None
             self.set_song(song, play, self.get_crossfade() * 2, seek)
     self.emit("loaded")        
Beispiel #4
0
def get_receive_errors(rev_old, rev_new, file_type, function):
    checkable = True
    if file_type == "js":
        checkable = config.getboolean("receive", "CHECK_JAVASCRIPT")
    elif file_type == "php":
        checkable = config.getboolean("receive", "CHECK_PHP")

    if not checkable:
        return None

    files = _get_receive_files(rev_old, rev_new, file_type)
    if not files:
        return None

    tmp_dir = config.get("receive", "TMP_DIR")
    errors = []
    for file_path in files:
        mkdir("-p", "/".join((tmp_dir + file_path).split("/")[:-1]))
        system("git show %s:%s > %s" %
               (rev_new, file_path, tmp_dir + file_path))
        if path.exists(tmp_dir + file_path):
            file_error = function(tmp_dir + file_path)
            if file_error:
                errors.append(file_path + file_error)

    rm("-rf", tmp_dir)
    return "\n".join(errors)
 def multiple_engine(self, song, lrc_path, artist, title):    
     try:
         ret = False
         result = TTPlayer().request(artist, title)
         if result:
             if config.getboolean("lyrics", "auto_download"):
                 ret = utils.download(result[0][2], lrc_path)
                 if ret and self.vaild_lrc(lrc_path):
                     return lrc_path
                 else:
                     os.unlink(lrc_path)
                     
         duomi_result = DUOMI().request(artist, title)
         if duomi_result:
             if config.getboolean("lyrics", "auto_download"):
                 ret = utils.download(duomi_result[0][2], lrc_path, "gbk")
                 if ret and self.vaild_lrc(lrc_path):
                     return lrc_path
                 else:
                     os.unlink(lrc_path)
                     
         soso_result =  SOSO().request(artist, title)
         if soso_result:
             if config.getboolean("lyrics", "auto_download"):
                 ret = utils.download(soso_result[0][2], lrc_path, "gb18030")
                 if ret and self.vaild_lrc(lrc_path):
                     return lrc_path
                 else:
                     os.unlink(lrc_path)
     except:
         return None
Beispiel #6
0
 def draw_control(self, cr, allocation, alpha):
     rect = gtk.gdk.Rectangle(allocation.x, allocation.y, allocation.width, allocation.height)
     cr.push_group()
     
     # Draw lyrics button
     rect.x += self.lyrics_padding_left
     enable_lyrics = config.getboolean('lyrics', 'status')
     if enable_lyrics:
         lyrics_pixbuf = app_theme.get_pixbuf('mini/lyrics_active_normal.png').get_pixbuf()
     else:
         lyrics_pixbuf = app_theme.get_pixbuf('mini/lyrics_inactive_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - lyrics_pixbuf.get_height()) / 2
     draw_pixbuf(cr, lyrics_pixbuf, rect.x, icon_y)
     
     # Draw previous button.
     rect.x += lyrics_pixbuf.get_width() + self.lyrics_padding_right
     previous_pixbuf = app_theme.get_pixbuf('mini/previous_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - previous_pixbuf.get_height()) / 2
     draw_pixbuf(cr, previous_pixbuf, rect.x, icon_y)
     
     # Draw playpause button.
     rect.x += previous_pixbuf.get_width()
     is_played = config.getboolean('player', 'play')
     if is_played:
         playpause_pixbuf = app_theme.get_pixbuf('mini/pause_normal.png').get_pixbuf()
     else:
         playpause_pixbuf = app_theme.get_pixbuf('mini/play_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - playpause_pixbuf.get_height()) / 2
     draw_pixbuf(cr, playpause_pixbuf, rect.x, icon_y)
     
     # Draw next button.
     rect.x += playpause_pixbuf.get_width()
     next_pixbuf = app_theme.get_pixbuf('mini/next_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - next_pixbuf.get_height()) / 2
     draw_pixbuf(cr, next_pixbuf, rect.x, icon_y)
     
     # Draw volume button.
     (v_w, v_h,) = self.volume_slider.volume_button.get_size()
     v_y = rect.y + (rect.height - v_h) / 2
     rect.x += self.volume_padding_left + next_pixbuf.get_width()
     volume_button_rect = gtk.gdk.Rectangle(rect.x, v_y, v_w, v_h)
     self.volume_slider.volume_button.draw_volume(cr, volume_button_rect)
     
     # Draw event box, draw close button.
     close_pixbuf = ui_theme.get_pixbuf('button/window_close_normal.png').get_pixbuf()
     event_box_x = rect.width - close_pixbuf.get_width() + 4
     draw_pixbuf(cr, close_pixbuf, event_box_x, rect.y)
     
     # Draw min button.
     min_pixbuf = ui_theme.get_pixbuf('button/window_min_normal.png').get_pixbuf()
     event_box_x -= min_pixbuf.get_width()
     draw_pixbuf(cr, min_pixbuf, event_box_x, rect.y)
     
     # draw quell button.
     quell_pixbuf = app_theme.get_pixbuf('mode/quell_normal.png').get_pixbuf()
     event_box_x -= quell_pixbuf.get_width()
     draw_pixbuf(cr, quell_pixbuf, event_box_x, rect.y)
     
     cr.pop_group_to_source()
     cr.paint_with_alpha(alpha)
Beispiel #7
0
    def update_menu(self):
        menu_items = []
        if Player.is_paused():
            pixbuf_group = self.get_pixbuf_group("play")
            status_label = _("Play")
        else:
            pixbuf_group = self.get_pixbuf_group("pause")
            status_label = _("Pause")
        menu_items.append((pixbuf_group, status_label, Player.playpause))
        menu_items.append((self.get_pixbuf_group("previous"), _("Previous"), Player.previous))
        menu_items.append((self.get_pixbuf_group("next"), _("Next"), Player.next))
        menu_items.append(None)
        menu_items.append((self.get_pixbuf_group("volume"), _("Volume"), self.get_volume_menu()))
        menu_items.append(None)

        if config.getboolean("lyrics", "status"):
            menu_items.append((None, _("Close Lyrics"), lambda: Dispatcher.close_lyrics()))
            menu_items.append((None, _("Search Lyrics"), lambda: Dispatcher.emit("search-lyrics")))
        else:
            menu_items.append((None, _("Show Lyrics"), lambda: Dispatcher.show_lyrics()))

        if config.getboolean("lyrics", "locked"):
            menu_items.append((self.get_pixbuf_group("unlock"), _("Unlock Lyrics"), lambda: Dispatcher.unlock_lyrics()))
        else:
            menu_items.append((self.get_pixbuf_group("lock"), _("Lock Lyrics"), lambda: Dispatcher.lock_lyrics()))

        menu_items.append(None)
        menu_items.append((self.get_pixbuf_group("setting"), _("Preferences"), lambda: Dispatcher.show_setting()))
        menu_items.append((self.get_pixbuf_group("close"), _("Quit"), lambda: Dispatcher.quit()))
        if self.menu is not None:
            del self.menu
        self.menu = Menu(menu_items, True)
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		self.setPositioningToAbsolute = config.getboolean(name, 'positioning.absolute')
		self.setUnitsToMillimeters = config.getboolean(name, 'units.millimeters')
		self.startAtHome = config.getboolean(name, 'startup.at.home')
		self.resetExtruder = config.getboolean(name, 'startup.extruder.reset')
		self.endFile = config.get(name, 'end.file')
		self.startFile = config.get(name, 'start.file')
Beispiel #9
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.setPositioningToAbsolute = config.getboolean(name, 'positioning.absolute')
     self.setUnitsToMillimeters = config.getboolean(name, 'units.millimeters')
     self.startAtHome = config.getboolean(name, 'startup.at.home')
     self.resetExtruder = config.getboolean(name, 'startup.extruder.reset')
     self.endFile = config.get(name, 'end.file')
     self.startFile = config.get(name, 'start.file')
     self.layerHeight = self.slicedModel.runtimeParameters.layerHeight
Beispiel #10
0
def build_message():
    global message
    message = Group(Optional(Suppress(Literal(":")) + prefix + space)) + Group(command) + Group(Optional(params))
    if config.getboolean("parser", "trailing_spaces"):
        message += ZeroOrMore(space)
    if config.getboolean("parser", "soft_eol"):
        message += cr ^ lf ^ crlf
    else:
        message += crlf
    message.leaveWhitespace()
Beispiel #11
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.debug = config.getboolean(name, 'debug')
     self.deleteComments = config.getboolean(name, 'delete.comments')
     self.fileExtension = config.get(name, 'file.extension')
     self.nameOfReplaceFile = config.get(name, 'replace.filename')
     self.exportSlicedModel = config.getboolean(name, 'export.slicedmodel')
     self.exportSlicedModelExtension = config.get(name, 'export.slicedmodel.extension')
     self.addProfileExtension = config.getboolean(name, 'file.extension.profile')
     self.overwriteExportedSlicedModel = config.getboolean(name, 'overwrite.exported.slicedmodel')
    def update_render_color(self, obj, selection, option, value):
        color_option = [
            "inactive_color_upper",
            " inactive_color_middle",
            "inactive_color_bottom",
            "active_color_upper",
            "active_color_middle",
            "active_color_bottom",
        ]
        if selection == "lyrics" and option in color_option:
            self.update_font()

        if selection == "lyrics" and option == "status":
            status = config.getboolean("lyrics", "status")
            if not status:
                if self.time_source != 0:
                    gobject.source_remove(self.time_source)
            else:
                lrc_mode = config.getint("lyrics", "mode")
                if lrc_mode == 1:
                    self.time_source = gobject.timeout_add(200, self.check_mouse_leave)

        if selection == "lyrics" and option == "mode":
            lrc_mode = config.getint("lyrics", "mode")
            if lrc_mode != 1:
                if self.time_source != 0:
                    gobject.source_remove(self.time_source)
            else:
                status = config.getboolean("lyrics", "status")
                if status:
                    self.time_source = gobject.timeout_add(200, self.check_mouse_leave)

        if selection == "lyrics" and option == "font_name":
            self.set_font_name(value)

        if selection == "lyrics" and option == "font_size":
            self.set_font_size(int(value))

        if selection == "lyrics" and option == "font_type":
            self.set_font_type(value)

        if selection == "lyrics" and option == "line_count":
            if value == "1":
                self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", "single_line_align")]
            elif value == "2":
                self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", "double_line_align")]
            self.line_count = int(value)
            self.update_font()

        if selection == "lyrics" and option in ["single_line_align", "double_line_align"]:
            self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", option)]
            self.update_font()

        if selection == "lyrics" and option in ["outline_width", "blur_color"]:
            self.update_font()
Beispiel #13
0
	def __init__(self, slicedModel):
		'Initialize'
		self.slicedModel = slicedModel
		self.layerHeight = config.getfloat(name, 'layer.height')
		self.extrusionWidth = config.getfloat(name, 'extrusion.width')
		self.infillBridgeDirection = config.getboolean(name, 'infill.bridge.direction')
		self.importCoarsenessRatio = config.getfloat(name, 'import.coarseness.ratio')
		self.correctMesh = config.getboolean(name, 'mesh.correct')
		self.decimalPlaces = config.getint('general', 'decimal.places')
		self.layerPrintFrom = config.getint(name, 'layer.print.from')
		self.layerPrintTo = config.getint(name, 'layer.print.to')
Beispiel #14
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.overlapRemovalWidthOverPerimeterWidth = config.getfloat(name, "overlap.removal.scaler")
     self.nozzleDiameter = config.getfloat(name, "nozzle.diameter")
     self.bridgeWidthMultiplier = config.getfloat(name, "bridge.width.multiplier.ratio")
     self.loopOrderAscendingArea = config.getboolean(name, "loop.order.preferloops")
     self.layerThickness = self.slicedModel.runtimeParameters.layerThickness
     self.perimeterWidth = self.slicedModel.runtimeParameters.perimeterWidth
     self.halfPerimeterWidth = 0.5 * self.perimeterWidth
     self.overlapRemovalWidth = self.perimeterWidth * (0.7853) * self.overlapRemovalWidthOverPerimeterWidth
     self.multiprocess = config.getboolean(name, "multiprocess")
Beispiel #15
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.debug = config.getboolean(name, "debug")
     self.deleteComments = config.getboolean(name, "delete.comments")
     self.fileExtension = config.get(name, "file.extension")
     self.nameOfReplaceFile = config.get(name, "replace.filename")
     self.exportSlicedModel = config.getboolean(name, "export.slicedmodel")
     self.exportSlicedModelExtension = config.get(name, "export.slicedmodel.extension")
     self.addProfileExtension = config.getboolean(name, "file.extension.profile")
     self.overwriteExportedSlicedModel = config.getboolean(name, "overwrite.exported.slicedmodel")
     self.firstLayerFeedRateRatio = config.getfloat("speed", "feed.rate.first.layer.ratio")
     self.firstLayerFlowRateRatio = config.getfloat("speed", "flow.rate.first.layer.ratio")
Beispiel #16
0
def build_message():
    global message
    message = Group(Optional(Suppress(Literal(':')) + prefix + space)) + \
              Group(command) + \
              Group(Optional(params))
    if config.getboolean('parser', 'trailing_spaces'):
        message += ZeroOrMore(space)
    if config.getboolean('parser', 'soft_eol'):
        message += cr ^ lf ^ crlf
    else:
        message += crlf
    message.leaveWhitespace()
Beispiel #17
0
def build_message():
    global message
    message = Group(Optional(Suppress(Literal(':')) + prefix + space)) + \
              Group(command) + \
              Group(Optional(params))
    if config.getboolean('parser', 'trailing_spaces'):
        message += ZeroOrMore(space)
    if config.getboolean('parser', 'soft_eol'):
        message += cr ^ lf ^ crlf
    else:
        message += crlf
    message.leaveWhitespace()
Beispiel #18
0
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		
		self.turnFanOnAtBeginning = config.getboolean(name, 'turn.on.fan.at.beginning')
		self.turnFanOffAtEnding = config.getboolean(name, 'turn.off.fan.at.end')
		self.nameOfCoolStartFile = config.get(name, 'cool.start.file')
		self.nameOfCoolEndFile = config.get(name, 'cool.end.file')
		self.coolStrategyName = config.get(name, 'strategy')
		self.coolStrategyPath = config.get(name, 'strategy.path')
		self.absoluteCoolStartFilePath = os.path.join('alterations', self.nameOfCoolStartFile)
		self.absoluteCoolEndFilePath = os.path.join('alterations', self.nameOfCoolEndFile)
		self.coolStartLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
		self.coolEndLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
Beispiel #19
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel

        self.convex = config.getboolean(name, 'convex')
        self.gapOverPerimeterWidth = config.getfloat(name, 'gap.over.perimeter.width')
        self.layersTo = config.getint(name, 'layers.to.index')
        self.edgeWidth = slicedModel.runtimeParameters.extrusionWidth
        brimWidth = config.getfloat(name, 'brim.width')
        self.skirtGap = self.gapOverPerimeterWidth * self.edgeWidth + brimWidth
        self.brimLoopsCount = int(brimWidth / self.edgeWidth)
        self.outerInner = config.getboolean(name, 'order.outer.inner')
        self.unifiedLoop = LoopCrossDictionary()
        self.createSegmentDictionaries(self.unifiedLoop)
Beispiel #20
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel

        self.convex = config.getboolean(name, "convex")
        self.gapOverPerimeterWidth = config.getfloat(name, "gap.over.perimeter.width")
        self.layersTo = config.getint(name, "layers.to.index")
        self.edgeWidth = slicedModel.runtimeParameters.extrusionWidth
        brimWidth = config.getfloat(name, "brim.width")
        self.skirtGap = self.gapOverPerimeterWidth * self.edgeWidth + brimWidth
        self.brimLoopsCount = int(brimWidth / self.edgeWidth)
        self.outerInner = config.getboolean(name, "order.outer.inner")
        self.unifiedLoop = LoopCrossDictionary()
        self.createSegmentDictionaries(self.unifiedLoop)
Beispiel #21
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel

        self.turnFanOnAtBeginning = config.getboolean(name, 'turn.on.fan.at.beginning')
        self.turnFanOffAtEnding = config.getboolean(name, 'turn.off.fan.at.end')
        self.nameOfCoolStartFile = config.get(name, 'cool.start.file')
        self.nameOfCoolEndFile = config.get(name, 'cool.end.file')
        self.coolStrategyName = config.get(name, 'strategy')
        self.coolStrategyPath = config.get(name, 'strategy.path')
        self.absoluteCoolStartFilePath = os.path.join('alterations', self.nameOfCoolStartFile)
        self.absoluteCoolEndFilePath = os.path.join('alterations', self.nameOfCoolEndFile)
        self.coolStartLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
        self.coolEndLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
Beispiel #22
0
 def __init__(self, slicedModel):
     'Initialize'
     self.slicedModel = slicedModel
     self.layerHeight = config.getfloat(name, 'layer.height')
     self.extrusionWidth = config.getfloat(name, 'extrusion.width')
     self.infillBridgeDirection = config.getboolean(
         name, 'infill.bridge.direction')
     self.importCoarsenessRatio = config.getfloat(
         name, 'import.coarseness.ratio')
     self.correctMesh = config.getboolean(name, 'mesh.correct')
     self.decimalPlaces = config.getint('general', 'decimal.places')
     self.layerPrintFrom = config.getint(name, 'layer.print.from')
     self.layerPrintTo = config.getint(name, 'layer.print.to')
Beispiel #23
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.debug = config.getboolean(name, 'debug')
     self.deleteComments = config.getboolean(name, 'delete.comments')
     self.fileExtension = config.get(name, 'file.extension')
     self.nameOfReplaceFile = config.get(name, 'replace.filename')
     self.exportSlicedModel = config.getboolean(name, 'export.slicedmodel')
     self.exportSlicedModelExtension = config.get(
         name, 'export.slicedmodel.extension')
     self.addProfileExtension = config.getboolean(name,
                                                  'file.extension.profile')
     self.overwriteExportedSlicedModel = config.getboolean(
         name, 'overwrite.exported.slicedmodel')
Beispiel #24
0
 def update_render_color(self, obj, selection, option, value):    
     color_option  = ["inactive_color_upper", " inactive_color_middle", "inactive_color_bottom",
                      "active_color_upper", "active_color_middle", "active_color_bottom"]
     if selection == "lyrics" and option in color_option:
         self.update_font()
             
     if selection == "lyrics" and option == "status":        
         status = config.getboolean("lyrics", "status")
         if not status:
             if self.time_source != 0:
                 gobject.source_remove(self.time_source)
         else:    
             lrc_mode = config.getint("lyrics", "mode")
             if lrc_mode == 1:
                 self.time_source = gobject.timeout_add(200, self.check_mouse_leave)        
                 
     if selection == "lyrics" and option == "mode":            
         lrc_mode = config.getint("lyrics", "mode")
         if lrc_mode != 1:
             if self.time_source != 0:
                 gobject.source_remove(self.time_source)
         else:        
             status = config.getboolean("lyrics", "status")
             if status:
                 self.time_source = gobject.timeout_add(200, self.check_mouse_leave)
                 
     if selection == "lyrics" and option == "font_name":            
         self.set_font_name(value)
         
     if selection == "lyrics" and option == "font_size":    
         self.set_font_size(int(value))
         
     if selection == "lyrics" and option == "font_type":
         self.set_font_type(value)
         
     if selection == "lyrics" and option == "line_count":    
         if value == "1":
             self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", "single_line_align")]
         elif value == "2":    
             self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", "double_line_align")]
         self.line_count = int(value)    
         self.update_font()
         
     if selection == "lyrics" and option in ["single_line_align", "double_line_align"]:    
         self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", option)]
         self.update_font()
         
     if selection == "lyrics" and option in ["outline_width", "blur_color"]:    
         self.update_font()
Beispiel #25
0
def get_receive_errors(rev_old,
                       rev_new,
                       file_type,
                       function,
                       with_filename=True):
    checkable = True
    if file_type == "js":
        checkable = config.getboolean("receive", "CHECK_JAVASCRIPT")
    elif file_type == "php":
        checkable = config.getboolean("receive", "CHECK_PHP")

    if not checkable:
        return None
    # 改动文件的相对路径
    files = _get_receive_files(rev_old, rev_new, file_type)
    if not files:
        return None

    tmp_dir = config.get("receive", "TMP_DIR")
    errors = []
    for file_path in files:
        # 临时文件名
        source_file_path = tmp_dir + file_path
        mkdir("-p", "/".join(source_file_path.split("/")[:-1]))
        # 将文件内容写入临时文件
        show = getoutput("git show %s:%s > %s" %
                         (rev_new, file_path, source_file_path))
        if show != '':
            continue
        if path.exists(source_file_path):
            # cache
            checksum = _file_checksum(source_file_path)
            checked, msg = _get_cached_check_result(checksum, function)
            if checked:
                if len(msg) > 0:
                    error_msg = file_path + msg if with_filename else msg
                    errors.append(error_msg)
                continue
            file_error = function(source_file_path)
            if file_error:
                if with_filename:
                    error_msg = file_path + file_error
                else:
                    error_msg = file_error
                errors.append(error_msg)
            _set_check_cache(checksum, function, file_error)
    # 临时文件交给系统处理
    # rm("-rf", tmp_dir)
    return "\n".join(errors)
Beispiel #26
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.overlapRemovalWidthOverPerimeterWidth = config.getfloat(
         name, 'overlap.removal.scaler')
     self.nozzleDiameter = config.getfloat(name, 'nozzle.diameter')
     self.bridgeWidthMultiplier = config.getfloat(
         name, 'bridge.width.multiplier.ratio')
     self.loopOrderAscendingArea = config.getboolean(
         name, 'loop.order.preferloops')
     self.layerThickness = self.slicedModel.runtimeParameters.layerThickness
     self.perimeterWidth = self.slicedModel.runtimeParameters.perimeterWidth
     self.halfPerimeterWidth = 0.5 * self.perimeterWidth
     self.overlapRemovalWidth = self.perimeterWidth * (
         0.7853) * self.overlapRemovalWidthOverPerimeterWidth
     self.multiprocess = config.getboolean(name, 'multiprocess')
 def get_lrc(self, song, try_web=True):    
     
     lrc_path = self.get_lrc_filepath(song)
     
     # lrc already exist
     if os.path.exists(lrc_path):
         if self.vaild_lrc(lrc_path):
             return lrc_path
         else:
             os.unlink(lrc_path)
     
     # Search in local directory of the file
     if song.get("uri") != None and song.get_scheme() == "file":
         local_lrc = os.path.join(song.get_dir(), self.get_lrc_search_str(song))
         if os.path.exists(local_lrc):
             return local_lrc
                 
     if not config.getboolean("setting", "offline") and try_web and is_network_connected():
         
         trust_a = song.get_str("artist")
         trust_t = song.get_str("title")
         filename = song.get_filename()
         if "-" in filename:
             untrust_a = filename.split("-")[0].strip()
             untrust_t = filename.split("-")[1].strip()
         else:    
             untrust_a = song.get_str("artist")
             untrust_t = song.get_filename()
         trust_result = self.multiple_engine(song, lrc_path, trust_a, trust_t)
         if trust_result:
             return trust_result
         else:
             return self.multiple_engine(song, lrc_path, untrust_a, untrust_t)
     return ""
 def get_next_song(self, manual=False):
     del self.select_rows[:]
     self.queue_draw()
     self.reset_error_items()
     
     if self.is_empty():
         if config.getboolean("setting", "empty_random"):
             return MediaDB.get_random_song("local")
     else:    
         if manual:
             if config.get("setting", "loop_mode") != "random_mode":
                 return self.get_manual_song()
             else:
                 return self.get_random_song()
         
         elif config.get("setting", "loop_mode") == "list_mode":
             return self.get_manual_song()
         
         elif config.get("setting", "loop_mode") == "order_mode":            
             return self.get_order_song()
         
         elif config.get("setting", "loop_mode") == "single_mode":
             if self.highlight_item != None:
                 return self.highlight_item.get_song()
             
         elif config.get("setting", "loop_mode") == "random_mode":    
             return self.get_random_song()
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		self.isExtrusionActive = False
		self.layerIndex = 0
		self.layerLines = []
		self.lineIndex = 0
		self.lines = None
		self.oldLocation = None
		self.rowIndex = 0
		self.shouldAccumulate = True

		self.centerX = config.getfloat(name, 'center.x')
		self.centerY = config.getfloat(name, 'center.y')
		self.numberOfColumns = config.getint(name, 'columns')
		self.numberOfRows = config.getint(name, 'rows')
		self.reverseSequenceEveryOddLayer = config.getboolean(name, 'sequence.reverse.odd.layers')
		self.separationOverPerimeterWidth = config.getfloat(name, 'separation.over.perimeter.width')
		self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
		self.centerOffset = complex(self.centerX, self.centerY)
		cornerMaximumComplex = self.slicedModel.carvingCornerMaximum.dropAxis()
		cornerMinimumComplex = self.slicedModel.carvingCornerMinimum.dropAxis()

		self.extent = cornerMaximumComplex - cornerMinimumComplex
		self.shapeCenter = 0.5 * (cornerMaximumComplex + cornerMinimumComplex)
		self.separation = self.separationOverPerimeterWidth * abs(self.extrusionWidth)
		self.extentPlusSeparation = self.extent + complex(self.separation, self.separation)
		columnsMinusOne = self.numberOfColumns - 1
		rowsMinusOne = self.numberOfRows - 1
		self.arrayExtent = complex(self.extentPlusSeparation.real * columnsMinusOne, self.extentPlusSeparation.imag * rowsMinusOne)
		self.arrayCenter = 0.5 * self.arrayExtent
def get_commit_errors():
  checkable = config.getboolean("commit", "CHECK_JAVASCRIPT")
  if not checkable:
    return None

  files = get_commit_files('js')
  if not files:
    return None

  errors = []
  for path in files:
    file_errors = jshint(
      "--config",
      "%s/configs/jshint.json" % base_path,
      path,  _ok_code = [0, 2]
    )
    if file_errors:
      errors.append(str(file_errors))

  if errors:
    errors = colored(
      "There are some errors in below javascript files:\n", "red",
      attrs = ["dark"]
    ) + "\n".join(errors)

  return errors
Beispiel #31
0
    def show_instance_menu(self, obj, x, y):
        curren_view = self.playlist_ui.get_selected_song_view()
        menu_items = [
            (None, _("Add"), curren_view.get_add_menu()),
            (None, _("Controls"), self.get_play_control_menu()),
            (self.get_pixbuf_group("playmode"), _("Playback Order"), curren_view.get_playmode_menu()),
            None,
            (None, _("Equalizer"), lambda : self.equalizer_win.run()),
            (None, _("Convert"), self.get_convert_sub_menu()),
            None,
            self.get_app_mode_menu(),
            None,
            self.get_lyrics_menu_items(),
            self.get_locked_menu_items(),
            None,
            (None, _("View New Features"), self.show_wizard_win),            
            (self.get_pixbuf_group("setting"), _("Preferences"), lambda : self.preference_dialog.show_all()),
            None,
            (self.get_pixbuf_group("close"), _("Quit"), self.force_quit),
            ]
        
        if config.getboolean("lyrics", "status"):
            menu_items.insert(10, (None, _("Search Lyrics"), lambda : Dispatcher.emit("search-lyrics")))

        Menu(menu_items, True).show((x, y))
Beispiel #32
0
 def _setupVdsConnection(self):
     if self._mode == "file":
         return
     self.remoteHost = self._dst.split(":")[0]
     self.remotePort = self._vm.cif.serverPort
     try:
         self.remotePort = self._dst.split(":")[1]
     except:
         pass
     serverAddress = self.remoteHost + ":" + self.remotePort
     if config.getboolean("vars", "ssl"):
         self.destServer = vdscli.connect(
             serverAddress, useSSL=True, TransportClass=kaxmlrpclib.TcpkeepSafeTransport
         )
     else:
         self.destServer = kaxmlrpclib.Server("http://" + serverAddress)
     self.log.debug("Destination server is: " + serverAddress)
     try:
         self.log.debug("Initiating connection with destination")
         status = self.destServer.getVmStats(self._vm.id)
         if not status["status"]["code"]:
             self.log.error("Machine already exists on the destination")
             self.status = errCode["exist"]
     except:
         self.log.error(traceback.format_exc())
         self.status = errCode["noConPeer"]
Beispiel #33
0
async def start_server(server_section: str):
    socket = config.get(server_section, "socket", fallback=None)
    app = main_app
    method = "unknown"
    if server_section == "APIserver":
        app = api_app

    if socket:
        await start_socket(app, socket)
        method = socket
    else:
        host = config.get(server_section, "host")
        port = config.getint(server_section, "port")

        environ = os.environ.get("PA_BASEPATH", "/")

        if config.getboolean(server_section, "ssl"):
            try:
                chain = config.get(server_section, "ssl_fullchain")
                key = config.get(server_section, "ssl_privkey")
            except configparser.NoOptionError:
                logger.critical(
                    "SSL CONFIGURATION IS NOT CORRECTLY CONFIGURED. ABORTING LAUNCH."
                )
                sys.exit(2)

            await start_https(app, host, port, chain, key)
            method = f"https://{host}:{port}{environ}"
        else:
            await start_http(app, host, port)
            method = f"http://{host}:{port}{environ}"

    print(f"======== Starting {server_section} on {method} ========")
Beispiel #34
0
    def _setParameters(self, runtimeParameters):
        self.decimalPlaces = runtimeParameters.decimalPlaces
        self.dimensionDecimalPlaces = runtimeParameters.dimensionDecimalPlaces
        self.speedActive = runtimeParameters.speedActive
        self.bridgeFeedRateMinute = runtimeParameters.bridgeFeedRateMinute
        self.perimeterFeedRateMinute = runtimeParameters.perimeterFeedRateMinute
        self.extrusionFeedRateMinute = runtimeParameters.extrusionFeedRateMinute
        self.travelFeedRateMinute = runtimeParameters.travelFeedRateMinute
        self.extrusionUnitsRelative = runtimeParameters.extrusionUnitsRelative
        self.supportFeedRateMinute = runtimeParameters.supportFeedRateMinute

        self.dimensionActive = runtimeParameters.dimensionActive

        self.zDistanceRatio = 5.0

        self.layerThickness = runtimeParameters.layerThickness
        self.perimeterWidth = runtimeParameters.perimeterWidth
        self.absolutePositioning = config.getboolean('preface',
                                                     'positioning.absolute')
        self.flowRate = runtimeParameters.flowRate
        self.perimeterFlowRate = runtimeParameters.perimeterFlowRate
        self.bridgeFlowRate = runtimeParameters.bridgeFlowRate
        self.combActive = runtimeParameters.combActive

        self.minimumBridgeFeedRateMultiplier = runtimeParameters.minimumBridgeFeedRateMultiplier
        self.minimumPerimeterFeedRateMultiplier = runtimeParameters.minimumPerimeterFeedRateMultiplier
        self.minimumExtrusionFeedRateMultiplier = runtimeParameters.minimumExtrusionFeedRateMultiplier
        self.minimumTravelFeedRateMultiplier = runtimeParameters.minimumTravelFeedRateMultiplier
        self.minimumLayerFeedRateMinute = runtimeParameters.minimumLayerFeedRateMinute
 def next(self, maunal=False):    
     '''next song'''
     self.update_skipcount()
     if not self.__source:
         return
     song = self.__source.get_next_song(maunal)
     if song:
         if config.getboolean("player", "crossfade") and config.getboolean("player", "crossfade_gapless_album") and self.song and song.get("album") == self.song.get("album"):        
             self.logdebug("request gapless to the backend")
             self.play_new(song, 0)
         else:    
             self.play_new(song)
         return 
     else:
         # stop the current song
         self.fadeout_and_stop()
Beispiel #36
0
    def show_instance_menu(self, obj, x, y):
        curren_view = self.playlist_ui.get_selected_song_view()
        menu_items = [
            (None, _("Add"), curren_view.get_add_menu()),
            (None, _("Controls"), self.get_play_control_menu()),
            (self.get_pixbuf_group("playmode"), _("Playback Order"),
             curren_view.get_playmode_menu()),
            None,
            (None, _("Equalizer"), lambda: self.equalizer_win.run()),
            (None, _("Convert"), self.get_convert_sub_menu()),
            None,
            self.get_app_mode_menu(),
            None,
            self.get_lyrics_menu_items(),
            self.get_locked_menu_items(),
            None,
            (None, _("View New Features"), self.show_wizard_win),
            (self.get_pixbuf_group("setting"), _("Preferences"),
             lambda: self.preference_dialog.show_all()),
            None,
            (self.get_pixbuf_group("close"), _("Quit"), self.force_quit),
        ]

        if config.getboolean("lyrics", "status"):
            menu_items.insert(10, (None, _("Search Lyrics"),
                                   lambda: Dispatcher.emit("search-lyrics")))

        Menu(menu_items, True).show((x, y))
Beispiel #37
0
 def set_dock_mode(self, value):
     if config.getboolean("lyrics", "dock_mode"):
         config.set("lyrics", "dock_mode", "false")
         self.set_type_hint(gtk.WINDOW_TYPE_HINT_NORMAL)
     else:    
         config.set("lyrics", "dock_mode", "true")
         self.set_type_hint(gtk.WINDOW_TYPE_HINT_DOCK)
Beispiel #38
0
def email_template(toaddr, template_name, template_vars):
    # always store the email
    ps = store_template(toaddr, template_name, template_vars)

    # see if we're meant to send it right away
    if not config.getboolean('mailer', 'delayed_send'):
        try_send(ps)
Beispiel #39
0
def email_template(toaddr, template_name, template_vars):
    # always store the email
    ps = store_template(toaddr, template_name, template_vars)

    # see if we're meant to send it right away
    if not config.getboolean('mailer', 'delayed_send'):
        try_send(ps)
Beispiel #40
0
    def _setParameters(self, runtimeParameters):
        self.decimalPlaces = runtimeParameters.decimalPlaces
        self.dimensionDecimalPlaces = runtimeParameters.dimensionDecimalPlaces
        self.speedActive = runtimeParameters.speedActive
        self.bridgeFeedRateMinute = runtimeParameters.bridgeFeedRateMinute
        self.perimeterFeedRateMinute = runtimeParameters.perimeterFeedRateMinute
        self.extrusionFeedRateMinute = runtimeParameters.extrusionFeedRateMinute
        self.travelFeedRateMinute = runtimeParameters.travelFeedRateMinute
        self.extrusionUnitsRelative = runtimeParameters.extrusionUnitsRelative
        self.supportFeedRateMinute = runtimeParameters.supportFeedRateMinute

        self.dimensionActive = runtimeParameters.dimensionActive

        self.zDistanceRatio = 5.0

        self.layerThickness = runtimeParameters.layerThickness
        self.perimeterWidth = runtimeParameters.perimeterWidth
        self.absolutePositioning = config.getboolean('preface', 'positioning.absolute')
        self.flowRate = runtimeParameters.flowRate
        self.perimeterFlowRate = runtimeParameters.perimeterFlowRate
        self.bridgeFlowRate = runtimeParameters.bridgeFlowRate
        self.combActive = runtimeParameters.combActive

        self.minimumBridgeFeedRateMultiplier = runtimeParameters.minimumBridgeFeedRateMultiplier
        self.minimumPerimeterFeedRateMultiplier = runtimeParameters.minimumPerimeterFeedRateMultiplier
        self.minimumExtrusionFeedRateMultiplier = runtimeParameters.minimumExtrusionFeedRateMultiplier
        self.minimumTravelFeedRateMultiplier = runtimeParameters.minimumTravelFeedRateMultiplier
        self.minimumLayerFeedRateMinute = runtimeParameters.minimumLayerFeedRateMinute
Beispiel #41
0
async def register(request):
    allow_registration = config.getboolean("Access control",
                                           "allow_registration")
    if not allow_registration:
        return web.HTTPConflict(
            reason="This feature is disabled by administrator")

    username = await authorized_userid(request)
    if username:
        return web.HTTPOk()

    data = await request.json()
    username = data["username"]
    password = data["password"]
    if User.by_name(username):
        return web.HTTPConflict(reason="Username already taken")
    elif not username:
        return web.HTTPBadRequest(reason="Please provide a username")
    elif not password:
        return web.HTTPBadRequest(reason="Please provide a password")
    else:
        with db.atomic():
            u = User(name=username)
            u.set_password(password)
            u.save()
        response = web.HTTPOk()
        await remember(request, response, username)
        return response
Beispiel #42
0
async def create(request):
    allow_new_sessions = config.getboolean("Access control",
                                           "allow_new_sessions")
    if not allow_new_sessions:
        return web.HTTPConflict(
            reason="This feature is disabled by administrator")

    user = await check_authorized(request)
    data = await request.json()
    roomname = data["name"]
    if not roomname:
        return web.HTTPBadRequest()
    else:
        with db.atomic():
            default_options = LocationOptions.create()
            room = Room.create(name=roomname,
                               creator=user,
                               default_options=default_options)
            loc = Location.create(room=room, name="start", index=1)
            loc.create_floor()
            PlayerRoom.create(player=user,
                              room=room,
                              role=Role.DM,
                              active_location=loc)
            room.save()
        return web.HTTPOk()
Beispiel #43
0
    def get_banner(self, channel_info, try_web=True):
        banner_path = self.get_banner_path(channel_info.get("id", 0))
        temp_path = self.get_temp_banner_path(channel_info.get("id", 0))

        # Banner image already exist.
        if os.path.exists(banner_path):
            try:
                gtk.gdk.pixbuf_new_from_file(banner_path)
            except gobject.GError:
                try:
                    os.unlink(banner_path)
                except:
                    pass
            else:
                return banner_path

        # Download from remote
        if not config.getboolean(
                "setting", "offline") and try_web and is_network_connected():
            banner_url = channel_info.get("banner")
            if banner_url:
                ret = utils.download(banner_url, temp_path)
                if ret and self.cleanup_banner(temp_path, banner_path):
                    return banner_path

        return None
Beispiel #44
0
 def get_locked_menu_items(self):
     if config.getboolean("lyrics", "locked"):
         return (self.get_pixbuf_group("unlock"), _("Unlock lyrics"),
                 lambda: Dispatcher.unlock_lyrics())
     else:
         return (self.get_pixbuf_group("lock"), _("Lock lyrics"),
                 lambda: Dispatcher.lock_lyrics())
 def set_current_lrc(self, try_web=True, force_song=None):        
     ret = False
     if not force_song:
         force_song = self.current_song
     filename = self.lrc_manager.get_lrc(force_song, try_web)    
     if filename and os.path.exists(filename):
         if self.time_source != None:
             gobject.source_remove(self.time_source)
             self.time_source = None
             self.clear_lyrics()
         if try_web:
             gobject.idle_add(self.set_lrc_file, filename)
         else:    
             self.set_lrc_file(filename)
             ret = True
         self.set_duration(force_song.get("#duration"))    
         self.__find_flag = True
         if config.getboolean("lyrics", "status"):
             self.play_time_source()
     else:    
         if self.current_song != force_song:
             return 
         if self.time_source != None:
             gobject.source_remove(self.time_source)
             self.time_source = None
             self.clear_lyrics()
         if try_web:    
             self.set_message(self.get_default_message(force_song) + " "+ _("No lyrics found!"))
             self.scroll_lyrics.set_message(self.get_default_message(force_song) + " " +  _("No lyrics found!"))
         else:    
             self.set_search_fail_message(_("Searching for lyrics..."))
             self.scroll_lyrics.set_message(_("Searching for lyrics..."))
         self.__find_flag = False    
     return ret    
Beispiel #46
0
def create_logger(log_queue):
    """
    Create a logger with multiple handles.

    Parameters
    ----------
        log_queue : queue.Queue()
            The queue for the QueueHandler.
    """

    # Load settings
    level = logging.getLevelName(config['log']['level'])
    log_in_user_interface = config.getboolean('log', 'log_in_user_interface')
    save_to_file = config.getboolean('log', 'save_to_file')
    log_filename = config['log']['log_filename']

    # create a logger
    logger = logging.getLogger("FincLab")
    logger.setLevel(level)

    # Formatter
    formatter = logging.Formatter(
        fmt="%(asctime)s %(name)-12s %(levelname)-8s %(message)s",
        datefmt="%Y-%m-%d %H:%M:%S")
    formatter = logging.Formatter(fmt="%(name)-18s: %(message)s",
                                  datefmt="%Y-%m-%d %H:%M:%S")
    # create consoleHandler
    # console_handler = logging.StreamHandler()
    # console_handler.setLevel(logging.DEBUG)
    # console_handler.setFormatter(formatter)
    # logger.addHandler(console_handler)

    # create queue handler for the user interface
    if log_in_user_interface:
        queue_handler = logging.handlers.QueueHandler(log_queue)
        queue_handler.setLevel(level)
        queue_handler.setFormatter(formatter)
        logger.addHandler(queue_handler)

    # create a file handler to save log
    if save_to_file:
        file_handler = logging.FileHandler(log_filename, mode='w')
        file_handler.setLevel(level)
        file_handler.setFormatter(formatter)
        logger.addHandler(file_handler)

    return logger
 def __init__(self):
     self.min_dist_between_blobs = config.getint('MIN_DIST_BETWEEN_BLOBS')
     self.filter_by_area = [config.getboolean('FILTER_BY_AREA'),
                            config.getint('MIN_AREA'),
                            config.getint('MAX_AREA')]
     self.overlap_threshold = config.getfloat('OVERLAP_THRESHOLD')
     self.detections = []
     self.blob_assigner = HungarianAlgorithm()
Beispiel #48
0
 def get_crossfade(self):
     if config.getboolean("player", "crossfade"):
         try: crossfade = float(config.get("player", "crossfade_time"))
         except: crossfade = 3.5
         if crossfade > 50: crossfade = 3.5
     else:
         crossfade = -1
     return crossfade
Beispiel #49
0
 def __init__(self, gmitm, msg, external):
     self.branch = msg.via0.branch
     self.gmitm = gmitm
     self.cseq = msg.cseq
     self.isInvite = msg.method == 'INVITE'
     self.external = external
     self.cachedRequests  = {} # dict "method" of (msg, raw string of transformed message, addr)
     self.cachedResponses = {} # dict "method" of (msg, raw string of transformed message, addr, code)
     self.logtimer = config.getboolean(consts.SECTION, consts.LOGTIMERS)
     self.logtimer = False # too many output
     self.logbm = config.getboolean(consts.SECTION, consts.LOGBMEVENTS)
     self.sipdelay = config.getboolean(consts.SECTION, consts.SIPDELAY)
     self.log("created")
     if self.isInvite:
         self.set_timeout(config.getfloat(consts.SECTION, consts.TIMERB))
     else:
         self.set_timeout(config.getfloat(consts.SECTION, consts.TIMERF))
Beispiel #50
0
 def __on_config_set(self, ob, section, option, value):
     if section == "setting" and option == "use_tray":
         use_tray = config.getboolean(section, option)
         if self.tray_icon and not use_tray:
             self.tray_icon.destroy()
             self.tray_icon = None
         elif not self.tray_icon and use_tray:
             self.tray_icon = TrayIcon(self)
Beispiel #51
0
def get():
    caps = {}

    caps['kvmEnabled'] = \
                str(config.getboolean('vars', 'fake_kvm_support') or
                    os.path.exists('/dev/kvm')).lower()

    cpuInfo = CpuInfo()
    caps['cpuCores'] = str(cpuInfo.cores())
    caps['cpuSockets'] = str(cpuInfo.sockets())
    caps['cpuSpeed'] = cpuInfo.mhz()
    if config.getboolean('vars', 'fake_kvm_support'):
        caps['cpuModel'] = 'Intel(Fake) CPU'
        flags = set(cpuInfo.flags() + ['vmx', 'sse2', 'nx'])
        caps['cpuFlags'] = ','.join(flags) + 'model_486,model_pentium,' \
            'model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,' \
            'model_coreduo,model_core2duo,model_n270,model_Conroe,' \
            'model_Penryn,model_Nehalem,model_Opteron_G1'
    else:
        caps['cpuModel'] = cpuInfo.model()
        caps['cpuFlags'] = ','.join(cpuInfo.flags() +
                                    _getCompatibleCpuModels())

    caps.update(dsaversion.version_info)
    caps.update(netinfo.get())

    try:
        caps['hooks'] = hooks.installed()
    except:
        logging.debug('not reporting hooks', exc_info=True)

    caps['operatingSystem'] = osversion()
    caps['uuid'] = utils.getHostUUID()
    caps['packages2'] = _getKeyPackages()
    caps['emulatedMachines'] = _getEmulatedMachines()
    caps['ISCSIInitiatorName'] = _getIscsiIniName()
    caps['HBAInventory'] = storage.hba.HBAInventory()
    caps['vmTypes'] = ['kvm']

    caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024)
    caps['reservedMem'] = str(
        config.getint('vars', 'host_mem_reserve') +
        config.getint('vars', 'extra_mem_reserve'))
    caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead')

    return caps
Beispiel #52
0
 def __on_config_set(self, ob, section, option, value):        
     if section == "setting" and option == "use_tray":
         use_tray = config.getboolean(section, option)
         if self.tray_icon and not use_tray:
             self.tray_icon.destroy()
             self.tray_icon = None
         elif not self.tray_icon and use_tray:    
             self.tray_icon = TrayIcon(self)
    def __init__(self):
        self.subtractor = cv2.createBackgroundSubtractorMOG2()

        self.subtractor.setHistory(config.getint('HISTORY'))
        self.subtractor.setDetectShadows(config.getboolean('DETECT_SHADOWS'))
        self.subtractor.setShadowThreshold(config.getfloat('SHADOW_THRESHOLD'))
        self.subtractor.setShadowValue(0)
        self.subtractor.setNMixtures(config.getint('N_MIXTURES'))
Beispiel #54
0
def get_commit_errors(file_type, function):
    checkable = True
    if file_type == "js":
        checkable = config.getboolean("commit", "CHECK_JAVASCRIPT")
    elif file_type == "php":
        checkable = config.getboolean("commit", "CHECK_PHP")

    if not checkable:
        return None

    files = _get_commit_files(file_type)
    if not files:
        return None

    # Get files are both in cached zone and modified zone
    system("git diff --name-status > /tmp/git_hook")
    modified_files = _get_files(file_type, 2)
    if modified_files:
        # Ask user whether add a file in modified zone to commit
        modified_files = [
            modified_file for modified_file in modified_files
            if modified_file in files
        ]
        stdin = open('/dev/tty')
        for modified_file in modified_files:
            print(
                'File %s has been modified but not in the cached zone, add it into ? [Y|n]'
                % colored(modified_file, 'red'))
            if not stdin.readline().strip().lower().startswith('n'):
                system('git add %s' % modified_file)

        stdin.close()

    errors = []
    for file_path in files:
        if path.exists(file_path):
            file_error = function(file_path)
            if file_error:
                errors.append(file_error)

    if errors:
        errors = colored(
            "There are some errors in below %s files:\n\n" % file_type,
            "magenta") + "\n".join(errors).strip("\n")

    return errors
Beispiel #55
0
def get():
    caps = {}

    caps['kvmEnabled'] = \
                str(config.getboolean('vars', 'fake_kvm_support') or
                    os.path.exists('/dev/kvm')).lower()

    cpuInfo =  CpuInfo()
    caps['cpuCores'] = str(cpuInfo.cores())
    caps['cpuSockets'] = str(cpuInfo.sockets())
    caps['cpuSpeed'] = cpuInfo.mhz()
    if config.getboolean('vars', 'fake_kvm_support'):
        caps['cpuModel'] = 'Intel(Fake) CPU'
        flags = set(cpuInfo.flags() + ['vmx', 'sse2', 'nx'])
        caps['cpuFlags'] = ','.join(flags) + 'model_486,model_pentium,' \
            'model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,' \
            'model_coreduo,model_core2duo,model_n270,model_Conroe,' \
            'model_Penryn,model_Nehalem,model_Opteron_G1'
    else:
        caps['cpuModel'] = cpuInfo.model()
        caps['cpuFlags'] = ','.join(cpuInfo.flags() +
                                    _getCompatibleCpuModels())

    caps.update(dsaversion.version_info)
    caps.update(netinfo.get())

    try:
        caps['hooks'] = hooks.installed()
    except:
        logging.debug('not reporting hooks', exc_info=True)

    caps['operatingSystem'] = osversion()
    caps['uuid'] = utils.getHostUUID()
    caps['packages2'] = _getKeyPackages()
    caps['emulatedMachines'] = _getEmulatedMachines()
    caps['ISCSIInitiatorName'] = _getIscsiIniName()
    caps['HBAInventory'] = storage.hba.HBAInventory()
    caps['vmTypes'] = ['kvm']

    caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024)
    caps['reservedMem'] = str(
            config.getint('vars', 'host_mem_reserve') +
            config.getint('vars', 'extra_mem_reserve') )
    caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead')

    return caps
Beispiel #56
0
 def __init__(self):
     self.strip = PixelStrip(config.getint(CONFIG_PREFIX, 'count'),
                             config.getint(CONFIG_PREFIX, 'pin'),
                             config.getint(CONFIG_PREFIX, 'freq_hz'),
                             config.getint(CONFIG_PREFIX, 'dma'),
                             config.getboolean(CONFIG_PREFIX, 'invert'),
                             config.getint(CONFIG_PREFIX, 'brightness'),
                             config.getint(CONFIG_PREFIX, 'channel'))
     self.strip.begin()
     self.effect: Optional[Effect] = None
Beispiel #57
0
 def __init__(self, *, source, heads, seq_no, is_block, env):
     self.timestamp = env.now
     self.seq_no = seq_no
     self.source = source
     self.heads = heads
     if config.getboolean('shares', 'simple_hash'):
         self.hash = self.get_simple_hash()
     else:
         self.hash = self.get_hash()
     self.is_block = is_block
Beispiel #58
0
    def update_menu(self):
        menu_items = []
        if Player.is_paused():
            pixbuf_group = self.get_pixbuf_group("play")
            status_label = _("Play")
        else:
            pixbuf_group = self.get_pixbuf_group("pause")
            status_label = _("Pause")
        menu_items.append((pixbuf_group, status_label, Player.playpause))
        menu_items.append((self.get_pixbuf_group("previous"), _("Previous"),
                           Player.previous))
        menu_items.append(
            (self.get_pixbuf_group("next"), _("Next"), Player.next))
        menu_items.append(None)
        menu_items.append((self.get_pixbuf_group("volume"), _("Volume"),
                           self.get_volume_menu()))
        menu_items.append(None)

        if config.getboolean("lyrics", "status"):
            menu_items.append(
                (None, _("Close Lyrics"), lambda: Dispatcher.close_lyrics()))
            menu_items.append((None, _("Search Lyrics"),
                               lambda: Dispatcher.emit("search-lyrics")))
        else:
            menu_items.append(
                (None, _("Show Lyrics"), lambda: Dispatcher.show_lyrics()))

        if config.getboolean("lyrics", "locked"):
            menu_items.append(
                (self.get_pixbuf_group("unlock"), _("Unlock Lyrics"),
                 lambda: Dispatcher.unlock_lyrics()))
        else:
            menu_items.append((self.get_pixbuf_group("lock"), _("Lock Lyrics"),
                               lambda: Dispatcher.lock_lyrics()))

        menu_items.append(None)
        menu_items.append((self.get_pixbuf_group("setting"), _("Preferences"),
                           lambda: Dispatcher.show_setting()))
        menu_items.append((self.get_pixbuf_group("close"), _("Quit"),
                           lambda: Dispatcher.quit()))
        if self.menu is not None:
            del self.menu
        self.menu = Menu(menu_items, True)