コード例 #1
0
ファイル: parcelwatch.py プロジェクト: thekvs/parcelwatch
def main(opts, conf):
    package_delivered_rx = re.compile("Вручение")
    cache = load_cache(conf)

    if not opts.shell:
        handle = RussianPostQuery()

        sms_user = conf.get("sms", "comtube_user")
        sms_password = conf.get("sms", "comtube_password")
        mobile = conf.get("sms", "mobile")

        sms = ComtubeRuSMS(sms_user, sms_password, mobile)

        email_server = conf.get("email", "server")
        email_user = conf.get("email", "user")
        email_password = conf.get("email", "password")
        email_to = conf.get("email", "to")
        email_from = email_user

        delete_delivered = conf.getboolean("misc", "autodelete_delivered")

        email = Email(email_server, email_user, email_password,
            email_to, email_from)
        delivered = set()

        for identifier, tracking_data in cache.items():
            try:
                events = handle.query(identifier.strip())
                logging.info("processing tracking number %s", identifier)
                if not events: continue
            except URLError as e:
                logging.error("tracking number %s: %s", identifier, e)
            else:
                new_events = set(events) - set(tracking_data.events)
                if not new_events: continue

                cache[identifier].events = events
                if opts.disable_alerts: continue

                for event in new_events:
                    if tracking_data.desc:
                        msg = "Отправление %s [%s]: %s" % \
                            (identifier, tracking_data.desc, str(event))
                    else:
                        msg = "Отправление %s: %s" % (identifier, str(event))

                    send_notifications(sms, email, msg)

                    if delete_delivered and package_delivered_rx.search(msg):
                        delivered.add(identifier)

        for identifier in delivered:
            logging.info("package %s is delivered, removing" \
                " it from the monitoring", identifier)
            del cache[identifier]
    else:
        run_shell(cache)

    save_cache(conf, cache)
コード例 #2
0
ファイル: main.py プロジェクト: Maginx/git_home
def exist_man_page(path):
    retcode, stdout, stderr = run_shell("svn ls " + path, True)
    if not stdout.__contains__("pom.xml"):
        return True
    print "ERROR : " + path.strip() + " still has the pom.xml \n"
    File.log(SVN_FAILED, path.strip() + " still has the pom.xml")
    return False
コード例 #3
0
ファイル: get_fm_adaptations.py プロジェクト: Maginx/git_home
def get_release_urls(path):
  i = 1
  release_names = {}
  retcode, stdout, stderr = run_shell("svn ls " + path,True)
  for adaptation_id in stdout.strip(' ').split('\n'):
    if len(adaptation_id) == 0:
      continue
    code,releases,stderr = run_shell("svn ls " + path + adaptation_id,True)
    for release_id in releases.strip(' ').split('\n'):
      if len(release_id) == 0:
        continue
      else:
        if not re.match(r'.*(ADAPSUP|PM|root|robot|mediation|\.project|mei)',release_id,re.I):
          release_names[release_id] = path + adaptation_id + release_id
          print  "%(i)s " % locals() + path + adaptation_id + release_id
          i = i + 1
  return release_names
コード例 #4
0
def get_release_urls(path):
    i = 1
    release_names = {}
    retcode, stdout, stderr = run_shell("svn ls " + path, True)
    for adaptation_id in stdout.strip(' ').split('\n'):
        if len(adaptation_id) == 0:
            continue
        code, releases, stderr = run_shell("svn ls " + path + adaptation_id,
                                           True)
        for release_id in releases.strip(' ').split('\n'):
            if len(release_id) == 0:
                continue
            else:
                if not re.match(
                        r'.*(ADAPSUP|PM|root|robot|mediation|\.project|mei)',
                        release_id, re.I):
                    release_names[
                        release_id] = path + adaptation_id + release_id
                    print "%(i)s " % locals(
                    ) + path + adaptation_id + release_id
                    i = i + 1
    return release_names
コード例 #5
0
ファイル: hv.py プロジェクト: reviczky/m1n1
    def handle_exception(self, reason, code, info):
        self.ctx = ctx = ExcInfo.parse(
            self.iface.readmem(info, ExcInfo.sizeof()))

        handled = False

        try:
            if code == EXC.SYNC:
                handled = self.handle_sync(ctx)
            elif code == EXC.FIQ:
                self.u.msr(CNTV_CTL_EL0, 0)
                self.u.print_exception(code, ctx)
                handled = True
        except Exception as e:
            print(f"Python exception while handling guest exception:")
            traceback.print_exc()

        if handled:
            ret = EXC_RET.HANDLED
        else:
            print(f"Guest exception: {code.name}")

            self.u.print_exception(code, ctx)

            locals = {
                "hv": self,
                "iface": self.iface,
                "p": self.p,
                "u": self.u,
            }

            for attr in dir(self):
                a = getattr(self, attr)
                if callable(a):
                    locals[attr] = getattr(self, attr)

            ret = shell.run_shell(locals, "Entering debug shell",
                                  "Returning from exception")

            if ret is None:
                ret = EXC_RET.EXIT_GUEST

        self.iface.writemem(info, ExcInfo.build(self.ctx))

        if ret == EXC_RET.HANDLED and self.step:
            ret = EXC_RET.STEP
        self.p.exit(ret)
コード例 #6
0
ファイル: hv.py プロジェクト: jannau/m1n1
    def handle_bark(self, reason, code, info):
        self._in_handler = True
        self._sigint_pending = False
        self._stepping = False

        locals = {
            "hv": self,
            "iface": self.iface,
            "p": self.p,
            "u": self.u,
        }

        for attr in dir(self):
            a = getattr(self, attr)
            if callable(a):
                locals[attr] = getattr(self, attr)

        signal.signal(signal.SIGINT, signal.SIG_DFL)
        ret = shell.run_shell(locals, "Entering panic shell", "Returning from exception")
        signal.signal(signal.SIGINT, self._handle_sigint)

        self.p.exit(0)
コード例 #7
0
ファイル: hv.py プロジェクト: jannau/m1n1
    def handle_exception(self, reason, code, info):
        self._in_handler = True

        info_data = self.iface.readmem(info, ExcInfo.sizeof())
        self.ctx = ctx = ExcInfo.parse(info_data)

        handled = False

        try:
            if reason == START.EXCEPTION_LOWER:
                if code == EXC.SYNC:
                    handled = self.handle_sync(ctx)
                elif code == EXC.FIQ:
                    self.u.msr(CNTV_CTL_EL0, 0)
                    self.u.print_exception(code, ctx)
                    handled = True
            elif reason == START.HV:
                code = HV_EVENT(code)
                if code == HV_EVENT.HOOK_VM:
                    handled = self.handle_vm_hook(ctx)
                elif code == HV_EVENT.VTIMER:
                    print("Step")
                    handled = True
                elif code == HV_EVENT.USER_INTERRUPT:
                    handled = True
        except Exception as e:
            print(f"Python exception while handling guest exception:")
            traceback.print_exc()

        if handled:
            ret = EXC_RET.HANDLED
            if self._sigint_pending:
                print("User interrupt")
        else:
            print(f"Guest exception: {reason.name}/{code.name}")
            self.u.print_exception(code, ctx)

        if self._sigint_pending or self._stepping or not handled:

            self._sigint_pending = False
            self._stepping = False

            locals = {
                "hv": self,
                "iface": self.iface,
                "p": self.p,
                "u": self.u,
            }

            for attr in dir(self):
                a = getattr(self, attr)
                if callable(a):
                    locals[attr] = getattr(self, attr)

            signal.signal(signal.SIGINT, signal.SIG_DFL)
            ret = shell.run_shell(locals, "Entering debug shell", "Returning from exception")
            signal.signal(signal.SIGINT, self._handle_sigint)

            if ret is None:
                ret = EXC_RET.EXIT_GUEST

        new_info = ExcInfo.build(self.ctx)
        if new_info != info_data:
            self.iface.writemem(info, new_info)

        if ret == EXC_RET.HANDLED and self._stepping:
            ret = EXC_RET.STEP
        self.p.exit(ret)

        self._in_handler = False
        if self._sigint_pending:
            self._handle_sigint()