예제 #1
0
파일: controllers.py 프로젝트: antroy/Home
    def add_note(self, item_id, text, id=None):
        note = Note(text=text, date=now(), user=user())
        idea = Idea.get(item_id)
        idea.addNote(note)

        tools.send_mail(item_id, "New Note added for idea '%(title)s'", note_id=note.id)

        redirect("/idea", redirect_params={'id':item_id})
예제 #2
0
    def actionPerformed(self, event):
        if self.message.Text.strip() == "" or self.subject.Text.strip() == "":
            self.msgbox.show("Please fill all fields!", "Attention", 2)
        else:
            from tools import send_mail
            try:
                send_mail(self.ctx, self.subject.Text.strip(),
                          self.message.Text.strip())
                self.subject.Text = ""
                self.message.Text = ""
            except:

                pass
예제 #3
0
파일: controllers.py 프로젝트: antroy/Home
    def add_action(self, item_id, text, assign_to, id=None):
        log.debug("item_id: '%s'; assign_to: '%s'" % (item_id, assign_to))
        ass_to = User.get(assign_to)
        log.debug("User: "******"Action created")
        idea = Idea.get(item_id)
        log.debug("Idea: " + idea.title)
        idea.addAction(action)
        log.debug("Action added")

        tools.send_mail(item_id, "New Action Added for idea '%(title)s'", action_id=action.id)

        redirect("/idea", redirect_params={'id':item_id})
예제 #4
0
def send_message():
    global message_log_string
    global error_counter
    if (error_counter > 0):
        subj = "[LogTM-Source] Regression Tester: %d TESTS FAILED" % error_counter
    else:
        subj = "[LogTM-Source] Regression Tester: SUCCESS"
    if os.environ.has_key("REGRESS") and os.environ["REGRESS"] == "true":
        recipients = ["[email protected], [email protected], [email protected], [email protected]"]
        #recipients = ["*****@*****.**"]
    else:
        recipients = [getpass.getuser()]
    tools.send_mail(message_log_string, "LogTM Regression Tester <*****@*****.**>", recipients, subj)
    print "Mail sent"
예제 #5
0
파일: controllers.py 프로젝트: antroy/Home
    def add(self, **kw):
        kw['date'] = now()
        kw['user'] = user()
        log.debug(str(kw))
        id = kw['id'].strip()
        log.debug("ID1: " + id)
        del kw['id']
        log.debug("ID2: " + id)

        categories = kw['categories']
        del kw['categories']

        status = kw['status'].strip()
        del kw['status']

        try:
            stat = Status(name=status)
        except DuplicateEntryError:
            stat = Status.byName(status)

        kw['status'] = stat

        log.debug("ID3: " + id)
        if not id:
            idea = Idea(**kw)
            
        else:
            idea = Idea.get(id)
            for k, v in kw.iteritems():
                if hasattr(idea, k):
                    setattr(idea, k, v)
            
        categories = re.split(r"[^a-z_-]+", categories.lower())
        
        for c in idea.categories:
            idea.removeCategory(c)

        for cat in categories:
            try:
                c = Category.byName(cat)
            except SQLObjectNotFound:
                c = Category(name=cat)

            idea.addCategory(c)

        if not id:
            tools.send_mail(idea.id, "New Idea added: '%(title)s'")

        redirect("/idea", redirect_params={'id':idea.id})
예제 #6
0
파일: views.py 프로젝트: evandu/jjehr
def book_course(request):
    if request.method == 'POST':
        form = EnrollForm(request.POST)
        if form.is_valid():
            _email = form._raw_value('email')
            _course = Course.objects.get(id=form._raw_value("course_id"))
            if _course.enrollStartTime > datetime.datetime.now() or _course.enrollEndTime < datetime.datetime.now():
                return HttpResponse(404)
            if Enroll.objects.filter(email=_email, course=_course).count() > 0:
                return HttpResponse(409)
            else:
                enroll = Enroll(email=_email, course=_course)
                seat_config = {v: k for k, v in dict(map(lambda f: [f[0], int(f[1])],
                                                         map(lambda x: x.split("#"),
                                                             _course.seatConfig.replace("\n", '').strip().split(
                                                                 "\r")))).items()}
                count = Enroll.objects.filter(course=_course).count() + 1
                while (count < _course.maxTraineeAmount and (not seat_config.has_key(count))):
                    count += 1
                if (seat_config.has_key(count)):
                    enroll.seat = seat_config.get(count)
                else:
                    enroll.seat = u'候选'
                    enroll.isWaitingList = True
                enroll.save()
                try:
                    import tools
                    course_name = "".join(_course.courseName.split())
                    if len(course_name) > 8:
                        course_name = course_name[0:7]
                    qr_code = tools.generate_QRcode(
                        u"{email}|{seat}|{courseName}|{courseDateTime}".format(
                            email=enroll.email.split('@')[0],
                            seat=enroll.seat,
                            courseName=_course.courseName,
                            courseDateTime=_course.courseStartTime.strftime('%Y-%m-%d %H:%M:%S')),
                        enroll.email)
                    tools.send_mail(_course, enroll, qr_code)
                except Exception as e:
                   # print e
                    enroll.delete()
                    return HttpResponse(500)
            return HttpResponse(200)
        else:
            return HttpResponse(400)
    else:
        return HttpResponse(403)
예제 #7
0
def send_message():
    global message_log_string
    global error_counter
    if (error_counter > 0):
        subj = "[LogTM-Source] Regression Tester: %d TESTS FAILED" % error_counter
    else:
        subj = "[LogTM-Source] Regression Tester: SUCCESS"
    if os.environ.has_key("REGRESS") and os.environ["REGRESS"] == "true":
        recipients = [
            "[email protected], [email protected], [email protected], [email protected]"
        ]
        #recipients = ["*****@*****.**"]
    else:
        recipients = [getpass.getuser()]
    tools.send_mail(message_log_string,
                    "LogTM Regression Tester <*****@*****.**>", recipients,
                    subj)
    print "Mail sent"
예제 #8
0
파일: controllers.py 프로젝트: antroy/Home
    def attach(self, upload_file, item_id, **kw):
        log.debug("Request Params:" + str(request.params.keys()))
        log.debug("kw Params:" + str(kw.keys()))
        
        fn = re.split(r"[\\/]", upload_file.filename)[-1]
        
        target_file_name = os.path.join(os.getcwd(), config.get("upload.dir"), fn)
        url = "./static/uploads/%s" % fn

        #try:
        #    att = Attachment.select(Attachment.q.filename == upload_file.filename,
        #                            Attachment.q.ideaID == item_id)
        #    att.date = now()
        #except SQLObjectNotFound:
        att = Attachment(date=now(), filename=fn, url=url, ideaID=item_id, user=user()) 

        f = open(target_file_name, 'wb')
        bytes = upload_file.file.read(1024)
        
        while bytes:
            f.write(bytes)
            bytes = upload_file.file.read(1024)

        f.close()

        try:
           man = images.Manipulator(target_file_name)
           man.createThumb()
        except:
           log.debug("Could not create thumbnail for file: " + target_file_name)
           import traceback
           log.debug("Trace:" + traceback.format_exc())

        
        tools.send_mail(item_id, "Attachment Added for idea '%(title)s'", attach_id=att.id)
            
        redirect("/idea", redirect_params={'id': item_id})
예제 #9
0
def main():

    machine_infos = tools.get_machine_infos()
    processes_to_monitor_pid = []
    processes_to_monitor = []

    while True:
        time.sleep(config.WAITING_TIME * 60)
        current_time = time.time()
        gpus_info = tools.gpus_snap_info()
        driver_version = gpus_info["driver_version"]
        news = ""
        send_info = False
        new_processes_count = 0
        died_processes_count = 0
        for index, gpu in enumerate(gpus_info["gpu"]):
            gpu_name = gpu["product_name"]
            processes = gpu["processes"]
            if processes == "N/A":
                news += f"Nothing is running on GPU {index} ({gpu_name})\n"
                continue
            else:
                for p in processes:
                    pid = p["pid"]
                    p_info = tools.process_info(pid)
                    if (current_time - p_info["since"] >=
                            config.PROCESS_AGE * 60
                            and not pid in processes_to_monitor_pid):
                        send_info = True
                        new_processes_count += 1
                        news += f"""

                        ---------------------------------------------------------------------------------------------------------------
                        A new process (PID : {pid}) has been launched on GPU {index} ({gpu_name}) by {p_info['owner']} since {datetime.datetime.fromtimestamp(int(p_info['since'])).strftime("%d/%m/%Y %H:%M:%S")}
                        His owner ({p_info['owner']}) has executed the following command :
                            {' '.join(p_info['executed_cmd'])}
                        From :
                            {p_info['from']}

                        CPU Status (currently):
                            For this process : {p_info['cpu_core_required']}

                        GPU Status (currently):
                            - Used memory (for this process): {p['used_memory']} / {gpu['fb_memory_usage']['total']} {gpu['fb_memory_usage']['unit']} ({round(p['used_memory']/gpu['fb_memory_usage']['total']*100,2)} % used)
                            - Used memory (for all processes running on this GPU) {gpu['fb_memory_usage']['used']} / {gpu['fb_memory_usage']['total']} {gpu['fb_memory_usage']['unit']} ({round(gpu['fb_memory_usage']['used']/gpu['fb_memory_usage']['total']*100,2)} % used)
                            - Temperature : {gpu["temperature"]["gpu_temp"]} Celsius
                            - Driver version : {driver_version}
                        ---------------------------------------------------------------------------------------------------------------


                        """
                        processes_to_monitor.append(p_info)
                        processes_to_monitor_pid.append(pid)
                    else:
                        continue

        for p in processes_to_monitor[:]:
            pid = p["pid"]
            try:
                still_running_p = psutil.Process(pid)
                continue
            except psutil.NoSuchProcess:
                send_info = True
                died_processes_count += 1
                news += f"""

                    ---------------------------------------------------------------------------------------------------------------
                    The process (PID : {pid}) launched by {p['owner']} since {datetime.datetime.fromtimestamp(int(p['since'])).strftime("%d/%m/%Y %H:%M:%S")} has ended.
                    His owner {p_info['owner']} had executed the following command :
                        {' '.join(p['executed_cmd'])}
                    From :
                        {p['from']}

                    The process took {datetime.timedelta(seconds=int(current_time)-int(p['since']))} to finish.
                    ---------------------------------------------------------------------------------------------------------------


                   """
                processes_to_monitor.remove(p)
                processes_to_monitor_pid.remove(pid)

        subject = None

        if new_processes_count > 0:
            subject = f"{new_processes_count} processes running on {machine_infos['MACHINE_NAME']} ({machine_infos['LOCAL_IP']})"
        elif died_processes_count > 0:
            subject = f"{died_processes_count} processes died on {machine_infos['MACHINE_NAME']} ({machine_infos['LOCAL_IP']})"
        else:
            subject = "Error"

        now = datetime.datetime.now()
        dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
        global_message = f"""                

            New events (triggered on the {dt_string}):
            {news}

            This message has been automatically send by a robot. Please don't answer to this mail.

            Please, feel free to open a merge request on github.com/araison12/gpus_monitor if you have encountered a bug or to share your ideas to improve this tool :)        

        """

        if send_info:
            for person in config.persons_to_inform():
                tools.send_mail(subject, global_message, person)
예제 #10
0
        Inputs = driver.find_element_by_name('rep_name')
        Inputs.send_keys('太田啓之')
        Inputs = driver.find_element_by_name('rep_tel')
        Inputs.send_keys('090-7422-1920')
        Inputs = driver.find_element_by_name('rep_email1')
        Inputs.send_keys('*****@*****.**')
        Inputs = driver.find_element_by_name('rep_email2')
        Inputs.send_keys('*****@*****.**')
        Inputs = driver.find_element_by_name('exp_date_y')
        Inputs.send_keys('{0:%Y}'.format(now))
        Inputs = driver.find_element_by_name('exp_date_m')
        Inputs.send_keys('{0:%m}'.format(now))
        Inputs = driver.find_element_by_name('exp_date_d')
        Inputs.send_keys('{0:%d}'.format(now))
        Inputs = driver.find_element_by_name('pat1_name')
        Inputs = driver.find_element_by_name('pat1_day1')
        Inputs.send_keys(f"{month1}月{day1}日 10:00 ~ {month2}月{day2}日 22:00")
        Inputs = driver.find_element_by_name('pat1_place')
        Inputs.send_keys('B1B2棟331, 326号室')
        Inputs = driver.find_element_by_name('pat1_naiyo')
        Inputs.send_keys(f"{naiyou}, 同伴者: {coworker}")
        Inputs = driver.find_element_by_name('risk1_name')
        Inputs.send_keys(naiyou)
        Inputs = driver.find_element_by_name('risk1_youin')
        Inputs.send_keys(youin)
        Inputs = driver.find_element_by_name('risk1_taisaku')
        Inputs.send_keys(taisaku)
    print('Text input is complete.')  #errorなく動作すると、cmdに「テキスト入力完了」と表示される
    send_mail(TO_ADDRESS, mail_text)
    print(mail_text)
예제 #11
0
if (__name__ == '__main__'):
    run_times = 0
    error_times = 0
    while 1:
        hour = random.choice(range(24))
        minute = random.choice(range(60))
        second = random.choice(range(60))
        print ('Random Weibo time:%s:%s:%s' % (hour, minute, second))
        print ('Now time is: %s' % time.asctime())

        if run_times < 3:
            run()
            run_times += 1
        else:
            error_times += 1
            print ("Have lots of Errors, take a rest~")
            t = 10 + error_times * error_times
            time.sleep(t)
            run_times = 0
            if error_times > 5:
                with open('./res/errors.log', 'r') as f:
                    a = str(f.readlines()[-20:])
                try:
                    send_mail(a)
                    print('Errors log has been sent to the specified mailbox.')
                    break
                except e:
                    print('Send mail error! Errors: %s.' % str(e))
                    break