def sendSuccessEmail(self, filename, metadata):
        email = metadata.get('user','')
        comments = self.markdown.convert(metadata.get('comments',''))
        if not email:
            logging.warning("error, no email stored %r %r" % (filename, metadata))
            return
        nickname = email.split('@')[0]
        if email == "*****@*****.**":
            email = "*****@*****.**"
        if metadata.get('gtfs_crawler','f') == 't':
            email = "*****@*****.**"
            
        text = """
Thank you for your participation in sharing 
transit schedule data with others. Open access
to data fosters inovation, and promotes transit
usage.        
        
The file you uploaded is now 
archived on GTFS Data Exchange as    
%(filename)s.

%(comments)s

You can view this file along with your comments at    
<http://www.gtfs-data-exchange.com/user/%(nickname)s/>
""" % {'filename':filename,'nickname':nickname,'comments':comments}
        EmailUtils.sendEmail(email,'GTFS Upload Successful',text)
        if email != "*****@*****.**":
            EmailUtils.sendEmail('*****@*****.**','GTFS File Uploaded','%(filename)s was uploaded by %(nickname)s' % {'filename':filename,'nickname':nickname,'comments':comments})
Example #2
0
def notify_user(request):
    """
    Notify the user
    """
    order_id = None
    email = None

    if request.method == "POST":
        if 'order_id' in request.POST:
            order_id = request.POST['order_id']
        if 'email' in request.POST:
            email = request.POST['email']


#
        if not order_id or not email:
            return

        order_lst = NewOrderRecord.objects.filter(order_serial_no=order_id)
        order = order_lst[0]
        state = order.order_state
        user = order.order_by_one
        print "Notifying the user [%s]; order state is [%s]" % (email, state)

        EmailUtils.notify_order_state_to_user(email, user, state)

    return HttpResponseRedirect('/administrator/')
Example #3
0
 def LoadAndRunTestCases(self):
     try:
         f = open(self.testcaselistfile)
         testfiles = [test for test in f.readlines() if not test.startswith("#")]
         f.close()
         for item in testfiles:
             subprocess.call("nosetests TestCasesRepository\\"+str(item).replace("\\n",""),shell = True)
     except Exception as err:
         LogUtility.logger.debug("Failed running test cases, error message: {}".format(str(err)))
     finally:
         EmailUtils.send_report()
Example #4
0
 def LoadAndRunTestCases(self):
     try:
         f = open(self.testcaselistfile)
         testfiles = [
             test for test in f.readlines() if not test.startswith("#")
         ]
         f.close()
         for item in testfiles:
             subprocess.call("nosetests TestCasesRepository\\" +
                             str(item).replace("\\n", ""),
                             shell=True)
     except Exception as err:
         LogUtility.logger.debug(
             "Failed running test cases, error message: {}".format(
                 str(err)))
     finally:
         EmailUtils.send_report()
Example #5
0
def handleBrokerNotification():
	notificationJsonString = list(request.form.to_dict().keys())[0]
	notificationDict = json.loads(notificationJsonString)
	channelName = notificationDict["channelName"]
	channelResultSet = channelName + "Results"
	subId = notificationDict["subscriptionIds"][0]
	# Get results using the subscription id
	subIdResults = json.loads(SubscriptionUtils.getResultUsingSubId(channelResultSet, subId))["results"]
	userId = SubscriptionUtils.getUserIdUsingSubId(subId)

	# Send Email
	emailBody = EmailUtils.generateEmailHtmlStrFromResults(subIdResults, subId, channelName)
	print(emailBody)
	EmailUtils.sendEmail(emailBody, userId)

	# Delete all the results
	SubscriptionUtils.deleteResultUsingSubId(channelResultSet, subId)
	return "Success"
Example #6
0
    def sendSuccessEmail(self, filename, metadata):
        email = metadata.get('user', '')
        comments = self.markdown.convert(metadata.get('comments', ''))
        if not email:
            logging.warning("error, no email stored %r %r" %
                            (filename, metadata))
            return
        nickname = email.split('@')[0]
        if email == "*****@*****.**":
            email = "*****@*****.**"
        if metadata.get('gtfs_crawler', 'f') == 't':
            email = "*****@*****.**"

        text = """
Thank you for your participation in sharing 
transit schedule data with others. Open access
to data fosters inovation, and promotes transit
usage.        
        
The file you uploaded is now 
archived on GTFS Data Exchange as    
%(filename)s.

%(comments)s

You can view this file along with your comments at    
<http://www.gtfs-data-exchange.com/user/%(nickname)s/>
""" % {
            'filename': filename,
            'nickname': nickname,
            'comments': comments
        }
        EmailUtils.sendEmail(email, 'GTFS Upload Successful', text)
        if email != "*****@*****.**":
            EmailUtils.sendEmail(
                '*****@*****.**', 'GTFS File Uploaded',
                '%(filename)s was uploaded by %(nickname)s' % {
                    'filename': filename,
                    'nickname': nickname,
                    'comments': comments
                })
    def send_error_email(self, key, msg):
        if tornado.options.options.shunt_s3:
            metadata = json.loads(open("/tmp/gtfs_s3/queue/" + key + ".meta", "rb").read())
        else:
            metadata = self.conn.head(self.bucket, key).object.metadata
        email = metadata.get('user','')
        if not email:
            logging.info('no email stored for key %r error %r' % (key, msg))
            return
        if metadata.get('gtfs_crawler','f') == 't':
            email = "*****@*****.**"
            msg += '\n' + str(metadata)
        
        text = """The following error was encountered while processing your GTFS upload.

%s

Please correct the error and re-try this upload.    
<http://www.gtfs-data-exchange.com/upload>    
""" % msg
        EmailUtils.sendEmail(email,'GTFS Upload Error',text)
Example #8
0
def summary(request):
    '''
    Summary
    '''

    user_name = request.session.get('username')

    #order_raw_list = NewOrderRecord.objects.values('order_serial_no').distinct().order_by('-order_serial_no')
    if user_name:
        order_dict = OrderUtils.get_today_order()
        history_order_dict = OrderUtils.get_last_n_order(5)
        param_dict = {'user_login': True, \
                     'user_name': user_name, \
                     'order_dict': order_dict, \
                     'history_order': history_order_dict}

        EmailUtils.notify_admin("*****@*****.**", param_dict)
        return render(request, 'summary.html', param_dict)

    else:
        return HttpResponseRedirect('/login/')
Example #9
0
    def send_error_email(self, key, msg):
        if tornado.options.options.shunt_s3:
            metadata = json.loads(
                open("/tmp/gtfs_s3/queue/" + key + ".meta", "rb").read())
        else:
            metadata = self.conn.head(self.bucket, key).object.metadata
        email = metadata.get('user', '')
        if not email:
            logging.info('no email stored for key %r error %r' % (key, msg))
            return
        if metadata.get('gtfs_crawler', 'f') == 't':
            email = "*****@*****.**"
            msg += '\n' + str(metadata)

        text = """The following error was encountered while processing your GTFS upload.

%s

Please correct the error and re-try this upload.    
<http://www.gtfs-data-exchange.com/upload>    
""" % msg
        EmailUtils.sendEmail(email, 'GTFS Upload Error', text)