本文整理汇总了Python中scal3.utils.myRaise函数的典型用法代码示例。如果您正苦于以下问题:Python myRaise函数的具体用法?Python myRaise怎么用?Python myRaise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了myRaise函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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__)
示例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()
示例6: setText
def setText(self, text):
try:
num = float(textNumDecode(text))
except:
myRaise()
self.setDefault()
else:
self.setValue(num)
示例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
示例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
示例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)
示例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()
示例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
示例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)
示例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
示例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()
示例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