def checkpermissions(ddir, umode): """ see if ddir has umode permission and if not set them. """ try: uid = os.getuid() gid = os.getgid() except AttributeError: return try: stat = os.stat(ddir) except OSError: return if stat[ST_UID] != uid: try: os.chown(ddir, uid, gid) except: pass if S_IMODE(stat[ST_MODE]) != umode: try: os.chmod(ddir, umode) except: handle_exception()
def checkpermissions(ddir, umode): uid = os.getuid() gid = os.getgid() try: stat = os.stat(ddir) except OSError: return if stat[ST_UID] != uid: try: os.chown(ddir, uid, gid) except: pass if S_IMODE(stat[ST_MODE]) != umode: try: os.chmod(ddir, umode) except: handle_exception() pass
def strtotime(what): daymonthyear = 0 hoursmin = 0 try: dmyre = re.search('(\d+)-(\d+)-(\d+)', str(what)) if dmyre: (day, month, year) = dmyre.groups() day = int(day) month = int(month) year = int(year) if day <= calendar.monthrange(year, month)[1]: date = "%s %s %s" % (day, bdmonths[month], year) daymonthyear = time.mktime(time.strptime(date, "%d %b %Y")) else: return None else: dmre = re.search('(\d+)-(\d+)', str(what)) if dmre: year = time.localtime()[0] (day, month) = dmre.groups() day = int(day) month = int(month) if day <= calendar.monthrange(year, month)[1]: date = "%s %s %s" % (day, bdmonths[month], year) daymonthyear = time.mktime(time.strptime(date, "%d %b %Y")) else: return None hmsre = re.search('(\d+):(\d+):(\d+)', str(what)) if hmsre: (h, m, s) = hmsre.groups() h = int(h) m = int(m) s = int(s) if h > 24 or h < 0 or m > 60 or m < 0 or s > 60 or s < 0: return None hours = 60 * 60 * (int(hmsre.group(1))) hoursmin = hours + int(hmsre.group(2)) * 60 hms = hoursmin + int(hmsre.group(3)) else: hmre = re.search('(\d+):(\d+)', str(what)) if hmre: (h, m) = hmre.groups() h = int(h) m = int(m) if h > 24 or h < 0 or m > 60 or m < 0: return None hours = 60 * 60 * (int(hmre.group(1))) hms = hours + int(hmre.group(2)) * 60 else: hms = 0 if not daymonthyear and not hms: return None if daymonthyear == 0: heute = today() else: heute = daymonthyear return heute + hms except OverflowError: return None except ValueError: return None except Exception, ex: handle_exception() return None
pass try: speed = o['--speed'] ievent.speed = int(speed) except KeyError: pass try: ievent.channel = o['--chan'] except KeyError: pass ievent.options.update(o) if args: ievent.txt = args[0] + ' ' + ' '.join(rest) makeargrest(ievent) except Exception, ex: handle_exception() return return ievent.options def makeargrest(ievent): """ create ievent.args and ievent.rest .. this is needed because \ ircevents might be created outside the parse() function """ try: ievent.args = ievent.txt.split()[1:] except ValueError: ievent.args = [] try: cmnd, ievent.rest = ievent.txt.split(' ', 1) except ValueError: ievent.rest = ""
pass try: speed = o['--speed'] ievent.speed = int(speed) except KeyError: pass try: ievent.channel = o['--chan'] except KeyError: pass ievent.options.update(o) if args: ievent.txt = args[0] + ' ' + ' '.join(rest) makeargrest(ievent) except Exception, ex: handle_exception() return return ievent.options def makeargrest(ievent): """ create ievent.args and ievent.rest .. this is needed because \ ircevents might be created outside the parse() function """ try: ievent.args = ievent.txt.split()[1:] except ValueError: ievent.args = [] try: cmnd, ievent.rest = ievent.txt.split(' ', 1) except ValueError: ievent.rest = "" ievent.command = ievent.txt.split(' ')[0]
def run(self): enable_handler() try: self.on_show() except Exception as E: handle_exception(E)