• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.myRaise函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scal3.utils.myRaise函数的典型用法代码示例。如果您正苦于以下问题:Python myRaise函数的具体用法?Python myRaise怎么用?Python myRaise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了myRaise函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: add

	def add(self, t0, t1, eid, debug=False):
		if debug:
			from time import strftime, localtime
			f = "%F, %T"
			print("EventSearchTree.add: %s\t%s\t%s" % (
				eid,
				strftime(f, localtime(t0)),
				strftime(f, localtime(t1)),
			))
		###
		if t0 == t1:
			t1 += epsTm ## needed? FIXME
		mt = (t0 + t1) / 2.0
		dt = (t1 - t0) / 2.0
		###
		try:
			self.root = self.addStep(
				self.root,
				t0, t1,
				mt, dt,
				eid,
			)
		except:
			myRaise()
		hp = self.byId.get(eid)
		if hp is None:
			hp = self.byId[eid] = MaxHeap()
		hp.push(mt, dt)## FIXME
开发者ID:ilius,项目名称:starcal,代码行数:28,代码来源:event_search_tree.py


示例2: makeWidget

def makeWidget(obj):
	"""
	obj is an instance of Event, EventRule, EventNotifier or EventGroup
	"""
	cls = obj.__class__
	try:
		WidgetClass = cls.WidgetClass
	except AttributeError:
		try:
			module = __import__(
				".".join([
					modPrefix,
					cls.tname,
					cls.name,
				]),
				fromlist=["WidgetClass"],
			)
			WidgetClass = cls.WidgetClass = module.WidgetClass
		except:
			myRaise()
			return
	widget = WidgetClass(obj)
	try:
		widget.show_all()
	except AttributeError:
		widget.show()
	widget.updateWidget()## FIXME
	return widget
开发者ID:ilius,项目名称:starcal,代码行数:28,代码来源:__init__.py


示例3: statusIconUpdateIcon

 def statusIconUpdateIcon(self, ddate):## FIXME
     from scal3.utils import toBytes
     imagePath = ui.statusIconImageHoli if ui.todayCell.holiday else ui.statusIconImage
     ext = os.path.splitext(imagePath)[1][1:].lower()
     loader = GdkPixbuf.PixbufLoader.new_with_type(ext)
     if ui.statusIconFixedSizeEnable:
         try:
             width, height = ui.statusIconFixedSizeWH
             loader.set_size(width, height)
         except:
             myRaise()
     data = open(imagePath).read()
     if ext == 'svg':
         dayNum = _(ddate[2])
         if ui.statusIconFontFamilyEnable:
             if ui.statusIconFontFamily:
                 family = ui.statusIconFontFamily
             else:
                 family = ui.getFont()[0]
             dayNum = '<tspan style="font-family:%s">%s</tspan>'%(family, dayNum)
         data = data.replace(
             'TX',
             dayNum,
         )
     data = toBytes(data)
     loader.write(data)
     loader.close()
     pixbuf = loader.get_pixbuf()
     self.sicon.set_from_pixbuf(pixbuf)
开发者ID:greyzero,项目名称:starcal,代码行数:29,代码来源:starcal.py


示例4: set_tooltip

def set_tooltip(widget, text):
    try:
        widget.set_tooltip_text(text)## PyGTK 2.12 or above
    except AttributeError:
        try:
            widget.set_tooltip(gtk.Tooltips(), text)
        except:
            myRaise(__file__)
开发者ID:greyzero,项目名称:starcal,代码行数:8,代码来源:utils.py


示例5: cleanup

	def cleanup(self):
		for fname in os.listdir(tmpDir):
			if not fname.startswith(self.imNamePrefix):
				continue
			try:
				os.remove(join(tmpDir, fname))
			except:
				myRaise()
开发者ID:ilius,项目名称:starcal,代码行数:8,代码来源:starcal_appindicator.py


示例6: setText

 def setText(self, text):
     try:
         num = float(textNumDecode(text))
     except:
         myRaise()
         self.setDefault()
     else:
         self.setValue(num)
开发者ID:greyzero,项目名称:starcal,代码行数:8,代码来源:multi_spin.py


示例7: imageFromFile

def imageFromFile(path):## the file must exist
    if not isabs(path):
        path = join(pixDir, path)
    im = gtk.Image()
    try:
        im.set_from_file(path)
    except:
        myRaise()
    return im
开发者ID:greyzero,项目名称:starcal,代码行数:9,代码来源:utils.py


示例8: pixbufFromFile

def pixbufFromFile(path):## the file may not exist
    if not path:
        return None
    if not isabs(path):
        path = join(pixDir, path)
    try:
        return GdkPixbuf.Pixbuf.new_from_file(path)
    except:
        myRaise()
        return None
开发者ID:greyzero,项目名称:starcal,代码行数:10,代码来源:utils.py


示例9: setText

	def setText(self, text):
		if text == "":
			self.setDefault()
			return
		try:
			num = int(float(textNumDecode(text)))
		except:
			print("IntField: invalid text = %r" % text)
			myRaise()
			self.setDefault()
		else:
			self.setValue(num)
开发者ID:ilius,项目名称:starcal,代码行数:12,代码来源:multi_spin.py


示例10: quit

 def quit(self, widget=None, event=None):
     try:
         ui.saveLiveConf()
     except:
         myRaise()
     if self.statusIconMode>1 and self.sicon:
         self.sicon.set_visible(False) ## needed for windows ## before or after main_quit ?
     self.destroy()
     ######
     core.stopRunningThreads()
     ######
     return gtk.main_quit()
开发者ID:greyzero,项目名称:starcal,代码行数:12,代码来源:starcal.py


示例11: getLoadedObj

	def getLoadedObj(self):
		try:
			module = __import__(
				self.moduleName,
				fromlist=["CalObj"],
			)
			CalObj = module.CalObj
		except:
			myRaise()
			return
		obj = CalObj()
		obj.enable = self.enable
		return obj
开发者ID:ilius,项目名称:starcal,代码行数:13,代码来源:customize.py


示例12: parseDroppedDate

def parseDroppedDate(text):
	part = text.split("/")
	if len(part) == 3:
		try:
			part[0] = numDecode(part[0])
			part[1] = numDecode(part[1])
			part[2] = numDecode(part[2])
		except:
			myRaise(__file__)
			return None
		maxPart = max(part)
		if maxPart > 999:
			minMax = (
				(1000, 2100),
				(1, 12),
				(1, 31),
			)
			formats = (
				[0, 1, 2],
				[1, 2, 0],
				[2, 1, 0],
			)
			for format in formats:
				for i in range(3):
					valid = True
					f = format[i]
					if not (minMax[f][0] <= part[i] <= minMax[f][1]):
						valid = False
						break
				if valid:
					# "format" must be list because we use method "index"
					year = part[format.index(0)]
					month = part[format.index(1)]
					day = part[format.index(2)]
					break
		else:
			valid = 0 <= part[0] <= 99 and \
				1 <= part[1] <= 12 and \
				1 <= part[2] <= 31
			###
			year = 2000 + part[0]  # FIXME
			month = part[1]
			day = part[2]
		if not valid:
			return None
	else:
		return None
	# FIXME: when drag from a persian GtkCalendar with format %y/%m/%d
	#if year < 100:
	#	year += 2000
	return (year, month, day)
开发者ID:ilius,项目名称:starcal,代码行数:51,代码来源:ui.py


示例13: checkAndSaveJsonLockFile

def checkAndSaveJsonLockFile(fpath):
	locked = False
	if isfile(fpath):
		try:
			text = open(fpath).read()
		except:
			myRaise()
			locked = True
		else:
			try:
				data = jsonToData(text)
			except:
				print('lock file %s is not valid'%fpath)
			else:
				try:
					pid = data['pid']
					cmd = data['cmd']
				except:
					print('lock file %s is not valid'%fpath)
				else:
					try:
						proc = psutil.Process(pid)
					except psutil.NoSuchProcess:
						print('lock file %s: pid %s does not exist'%(fpath, pid))
					else:
						if get_cmdline(proc) == cmd:
							locked = True
						else:
							print('lock file %s: cmd does match: %s != %s'%(fpath, get_cmdline(proc), cmd))
	elif exists(fpath):
		## what to do? FIXME
		pass
	######
	if not locked:
		my_pid = os.getpid()
		my_proc = psutil.Process(my_pid)
		my_cmd = get_cmdline(my_proc)
		my_text = dataToPrettyJson(OrderedDict([
			('pid', my_pid),
			('cmd', my_cmd),
			('time', now()),
		]))
		try:
			open(fpath, 'w').write(my_text)
		except Exception as e:
			print('failed to write lock file %s: %s'%(fpath, e))
		else:
			atexit.register(os.remove, fpath)
	######
	return locked
开发者ID:ubuntu-ir,项目名称:starcal,代码行数:50,代码来源:lockfile.py


示例14: doAction

	def doAction(self):
		container = self._container
		if self.iconRadio.get_active():
			chType = self.iconChangeCombo.get_active()
			if chType != 0:
				icon = self.iconSelect.get_filename()
				for event in container:
					if not (chType == 2 and event.icon):
						event.icon = icon
						event.afterModify()
						event.save()
		elif self.timeZoneRadio.get_active():
			chType = self.timeZoneChangeCombo.get_active()
			timeZone = self.timeZoneInput.get_text()
			if chType != 0:
				try:
					natz.gettz(timeZone)
				except:
					myRaise("Invalid Time Zone \"%s\"" % timeZone)
				else:
					for event in container:
						if not (chType == 2 and event.timeZone):
							event.timeZone = timeZone
							event.afterModify()
							event.save()
		else:
			chType = self.textChangeCombo.get_active()
			if chType != 0:
				text1 = self.textInput1.get_text()
				text2 = self.textInput2.get_text()
				if self.summaryRadio.get_active():
					for event in container:
						if chType == 1:
							event.summary = text1 + event.summary
						elif chType == 2:
							event.summary = event.summary + text1
						elif chType == 3:
							event.summary = event.summary.replace(text1, text2)
						event.afterModify()
						event.save()
				elif self.descriptionRadio.get_active():
					for event in container:
						if chType == 1:
							event.description = text1 + event.description
						elif chType == 2:
							event.description = event.description + text1
						elif chType == 3:
							event.description = event.description.replace(text1, text2)
						event.afterModify()
						event.save()
开发者ID:ilius,项目名称:starcal,代码行数:50,代码来源:bulk_edit.py


示例15: delete

	def delete(self, eid):
		hp = self.byId.get(eid)
		if hp is None:
			return 0
		else:
			n = 0
			for mt, dt in hp.getAll():
				try:
					self.root = self.deleteStep(self.root, mt, dt, eid)
				except:
					myRaise()
				else:
					n += 1
			del self.byId[eid]
			return n
开发者ID:ilius,项目名称:starcal,代码行数:15,代码来源:event_search_tree.py


示例16: delete

	def delete(self, eid):
		try:
			hp = self.byId[eid]
		except KeyError:
			return 0
		else:
			n = 0
			for mt, dt in hp.getAll():
				try:
					self.root = self.deleteStep(self.root, mt, dt, eid)
				except:
					myRaise()
				else:
					n += 1
			del self.byId[eid]
			return n
开发者ID:ubuntu-ir,项目名称:starcal,代码行数:16,代码来源:event_search_tree.py


示例17: treevCursorChanged

 def treevCursorChanged(self, selection):
     if self.activeOptionsWidget:
         try:
             self.vbox_l.remove(self.activeOptionsWidget)
         except:
             myRaise(__file__)
         self.activeOptionsWidget = None
     index_list = self.treev.get_cursor()[0]
     if not index_list:
         return
     item = self.getItemByPath(index_list)
     item.optionsWidgetCreate()
     if item.optionsWidget:
         item.optionsWidget.set_sensitive(item.enable)
         self.activeOptionsWidget = item.optionsWidget
         pack(self.vbox_l, item.optionsWidget)
         item.optionsWidget.show()
开发者ID:greyzero,项目名称:starcal,代码行数:17,代码来源:customize_dialog.py


示例18: decodeRemoteEvent

def decodeRemoteEvent(remoteEventFull, accountId, group):
	"""
	remoteEventFull is dict

	return (event, error)
	where event is instance of event_lib.Event, or None
	and error is string or None
	"""
	try:
		eventType = remoteEventFull["eventType"]
	except KeyError:
		return None, "bad remoteEventFull: missing \"eventType\""
	try:
		remoteEvent = remoteEventFull["data"]
	except KeyError:
		return None, "bad remoteEventFull: missing \"data\""
	try:
		decoder = remoteEventTypeDecoders[eventType]
	except KeyError:
		return None, "bad remoteEventFull: unkown type \"%s\"" % eventType
	eventData = {
		"summary": remoteEvent["summary"],
		"description": remoteEvent["description"],
		"calType": remoteEvent["calType"],
		"icon": remoteEvent["icon"],
		"timeZone": remoteEvent["timeZone"],
		"timeZoneEnable": remoteEvent["timeZoneEnable"],
	}
	try:
		eventTypeData = decoder(remoteEvent)
	except Exception as e:
		myRaise()
		return None, "bad remoteEvent: %s" % e
	eventData.update(eventTypeData)
	event = event_lib.classes.event.byName[eventType]()
	event.setData(eventData)
	event.remoteIds = (
		accountId,
		remoteEventFull["groupId"],  # remoteGroupId,
		remoteEventFull["eventId"],
		remoteEventFull["sha1"],
	)
	return event, None
开发者ID:ilius,项目名称:starcal,代码行数:43,代码来源:starcal.py


示例19: onExposeEvent

	def onExposeEvent(self, widget=None, event=None):
		cr = self.getContext()
		self.drawBg(cr)
		###
		w = self.get_allocation().width
		h = self.get_allocation().height
		###
		rowH = h / 7
		itemW = w - ui.wcalPadding
		for i in range(7):
			c = self.wcal.status[i]
			iconList = c.getWeekEventIcons()
			if not iconList:
				continue
			n = len(iconList)
			scaleFact = min(
				1.0,
				h / self.maxPixH,
				w / (n * self.maxPixW),
			)
			x0 = (w / scaleFact - (n - 1) * self.maxPixW) / 2
			y0 = (2 * i + 1) * h / (14 * scaleFact)
			if rtl:
				iconList.reverse()## FIXME
			for iconIndex, icon in enumerate(iconList):
				try:
					pix = GdkPixbuf.Pixbuf.new_from_file(icon)
				except:
					myRaise(__file__)
					continue
				pix_w = pix.get_width()
				pix_h = pix.get_height()
				x1 = x0 + iconIndex * self.maxPixW - pix_w / 2
				y1 = y0 - pix_h / 2
				cr.scale(scaleFact, scaleFact)
				gdk.cairo_set_source_pixbuf(cr, pix, x1, y1)
				cr.rectangle(x1, y1, pix_w, pix_h)
				cr.fill()
				cr.scale(1 / scaleFact, 1 / scaleFact)
开发者ID:ilius,项目名称:starcal,代码行数:39,代码来源:weekCal.py


示例20: statusIconUpdateIcon

	def statusIconUpdateIcon(self, ddate):  # FIXME
		from scal3.utils import toBytes
		imagePath = (
			ui.statusIconImageHoli if ui.todayCell.holiday
			else ui.statusIconImage
		)
		ext = os.path.splitext(imagePath)[1][1:].lower()
		loader = GdkPixbuf.PixbufLoader.new_with_type(ext)
		if ui.statusIconFixedSizeEnable:
			try:
				width, height = ui.statusIconFixedSizeWH
				loader.set_size(width, height)
			except:
				myRaise()
		data = open(imagePath, "rb").read()
		if ext == "svg":
			dayNum = locale_man.numEncode(
				ddate[2],
				mode=calTypes.primary,  # FIXME
			)
			if ui.statusIconFontFamilyEnable:
				if ui.statusIconFontFamily:
					family = ui.statusIconFontFamily
				else:
					family = ui.getFont()[0]
				dayNum = "<tspan style=\"font-family:%s\">%s</tspan>" % (
					family,
					dayNum,
				)
			data = data.replace(
				b"TX",
				toBytes(dayNum),
			)
		loader.write(data)
		loader.close()
		pixbuf = loader.get_pixbuf()
		self.sicon.set_from_pixbuf(pixbuf)
开发者ID:ilius,项目名称:starcal,代码行数:37,代码来源:starcal.py



注:本文中的scal3.utils.myRaise函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python scalaris.ScalarisVM类代码示例发布时间:2022-05-27
下一篇:
Python integer.IntSpinButton类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap