Exemplo n.º 1
0
def do_something_only_once():
    os.chdir(setDirectory.sethome())
    ExcelOperations.createFolder()
    setDirectory.makefinalfolder()
    print(os.getcwd())
    os.chdir(setDirectory.files())
    UserDetails.setUserlist()
    global questionsdict
    global questionsdict1
    global questionsdict2
    global questionsdict3
    global answerarray
    tempdict = {}
    tempdict2 = {}
    global total
    questionsdict, answerarray, total = ExcelOperations.exceltojson()
    y = json.dumps(questionsdict)
    x = json.loads(y)
    for qs in questionsdict:
        qsdict = {}
        tot = questionsdict[qs]['Total_qs']
        arr = questionsdict[qs]['Questions']
        arr = arr[int(tot / 2):] + arr[:int(tot / 2)]
        qsdict['Total_qs'] = tot
        qsdict['Questions'] = arr
        tempdict[qs] = qsdict
        qsdict = {}
        arr = questionsdict[qs]['Questions']
        arr = arr[int(tot / 3):] + arr[:int(tot / 3)]
        qsdict['Total_qs'] = tot
        qsdict['Questions'] = arr
        tempdict2[qs] = qsdict
    questionsdict3 = questionsdict.copy()
    questionsdict1 = tempdict.copy()
    questionsdict2 = tempdict2.copy()
def user_logout():

    token = request.cookies.get('token')

    if token is None:
        return json.dumps({"code": 200}), 200

    UserDetails.user_logout(token)

    response = Response(json.dumps({'code': 200}))
    return response
Exemplo n.º 3
0
    def getIssuesForUser(self, user):

        userDetails = UserDetails.UserDetails(self.jira)
        nameKey = userDetails.getNames(user=user)
        names = nameKey[0]
        key = nameKey[1]

        issues = []
        issueCount = 0
        issueTotal = 1

        while len(issues) < issueTotal:
            issueList = self.jira.search_issues(
                'worklogAuthor = ' + key + ' and worklogDate >= "' +
                str(self.workStartDate) + '" and worklogDate <= "' +
                str(self.workEndDate) + '"',
                fields="worklog,project",
                expand="worklog",
                startAt=str(len(issues)),
                maxResults=50)

            if len(issues) == 0:
                issues = issueList
            else:
                issues.extend(issueList)

            issueTotal = issueList.total

        issues = ResultList(issues, 0, len(issues), len(issues), True)

        return user, issues
Exemplo n.º 4
0
    def __init__(self,
                 user,
                 month,
                 year,
                 jira,
                 workStartDate=None,
                 workEndDate=None):
        self.user = user
        self.month = month
        self.year = year
        self.jira = jira

        self.daysInMonth = monthrange(self.year, self.month)[1]

        if user != None:
            userDetails = UserDetails.UserDetails(self.jira)
            nameKey = userDetails.getNames(user=self.user)
            self.names = nameKey[0]
            self.key = nameKey[1]

        if workStartDate is None:
            self.workStartDate = self.getDate(year=self.year,
                                              month=self.month,
                                              day=1)
        else:
            self.workStartDate = "" + str(workStartDate)

        if workEndDate is None:
            self.workEndDate = self.getDate(year=self.year,
                                            month=self.month,
                                            day=self.daysInMonth)
        else:
            self.workEndDate = "" + str(workEndDate)
def user_login():
    req = request.json
    email = req['email']
    password = req['password']
    status = 200
    error = ""

    if email is None:
        error = "Please provide email"
        status = 500

    if password is None:
        error = "Please provide Password"
        status = 500

    if status is not 500:
        token = UserDetails.user_login(email, password)

    if token is None:
        status = 500
        error = "Invalid Credentials"

    if status is 200:
        response = Response(json.dumps({'code': 200}))
        response.set_cookie('token', token)
        return response
    else:
        return json.dumps({"error": error}), status
Exemplo n.º 6
0
    def __init__(self,
                 jira,
                 user,
                 issue,
                 month,
                 year,
                 workStartDate=None,
                 workEndDate=None):
        self.jira = jira
        self.user = user
        self.issue = issue
        self.month = month
        self.year = year

        self.daysInMonth = monthrange(year, month)[1]
        self.offset = -5

        if issue != None:
            self.issueDetails = IssueDetails.IssueDetails(user=user,
                                                          month=month,
                                                          year=year,
                                                          jira=jira)

        if user != None:
            userDetails = UserDetails.UserDetails(jira=self.jira)
            nameKey = userDetails.getNames(user=user)
            self.names = nameKey[0]
            self.key = nameKey[1]

        startYear, startMonth, startDay = 1, 1, 1
        if workStartDate is not None:
            startYear = workStartDate.year
            startMonth = workStartDate.month
            startDay = workStartDate.day
        else:
            startYear = self.year
            startMonth = self.month
            startDay = 1

        self.workStartDate = self.getDateWithOffset(year=startYear,
                                                    month=startMonth,
                                                    day=startDay,
                                                    offset=self.offset)

        endYear, endMonth, endDay = 1, 1, 1
        if workEndDate is not None:
            endYear = workEndDate.year
            endMonth = workEndDate.month
            endDay = workEndDate.day
        else:
            endYear = self.year
            endMonth = self.month
            endDay = self.daysInMonth

        self.workEndDate = self.getDateWithOffset(year=endYear,
                                                  month=endMonth,
                                                  day=endDay,
                                                  offset=self.offset)
Exemplo n.º 7
0
def hello_world():
    if request.method == 'POST':
        y = json.loads(request.get_data())
        user = y[0]['Username']
        print(user)
        password = y[1]['Password']
        os.chdir(setDirectory.files())
        returnval, userid = UserDetails.UserPresent(user, password)
        y = {'result': returnval, 'userid': userid}
        return jsonify(y)
def user_signup():
    req = request.json
    firstName = req['firstName']
    lastName = req['lastName']
    email = req['email']
    password = req['password']

    status = 200
    error = ""

    if not firstName:
        error = "Please Provide First Name"
        status = 500

    if not lastName:
        error = "Please Provide Last Name"
        status = 500
    
    if not email or email is None:
        error = "Please Provide Email"
        status = 500

    if not valid_email(email):
        error = "Email is not valid"
        status = 500
    
    if password is None:
        error = "Please provide password"
        status = 500

    if status is not 500:
        token = UserDetails.user_signup(email, password, firstName, lastName)

    if token is None:
        error = "Please provide another email"
        status = 500

    if status is 200:
        resp = Response(json.dumps({'code': 200}))
        resp.set_cookie('token', token)
        return resp
    else:
        return json.dumps({"error": error}), status
def check_session():

    token = request.cookies.get('token')
    error = ""
    status = 200

    if token is None:
        error = "Invalid Login"
        status = 500
    
    if status is not 500:
        user = UserDetails.check_login(token)

    if user is None:
        error = "Invalid Login"
        status = 500

    name = user.get('firstName') + " " + user.get('lastName')
    if status is 200:
        response = Response(json.dumps({'code': 200, 'name': name}))
        return response
    else:
        return json.dumps({"error": error}), status
Exemplo n.º 10
0
def SendEmail(RecipientAddress):

    UserName, Password = UserDetails.ObtainUserCredentials()
    ExcelFiles, Subject = CreateSubjectLine()

    if (ExcelFiles == [] or Subject == ''):
        print 'No Excel Files Found'
        return False

    print 'Subject Line Generated'

    msg = MIMEMultipart()

    msg['From'] = UserName
    msg['To'] = ",".join(RecipientAddress)
    msg['Subject'] = Subject

    print 'Recipient Address List Ready'

    body = " "

    msg.attach(MIMEText(body, 'plain'))

    for file in ExcelFiles:
        attachment = open(file, "rb")

        part = MIMEBase('application', 'octet-stream')
        part.set_payload((attachment).read())
        encoders.encode_base64(part)
        part.add_header('Content-Disposition',
                        "attachment; filename= %s" % file)

        msg.attach(part)
        attachment.close()

    Data = msg.as_string()

    print 'Attachment Ready'

    try:
        server = smtplib.SMTP('smtp.rediffmail.com', 25)
        server.starttls()
        server.ehlo()
        server.esmtp_features["auth"] = "LOGIN PLAIN"
        server.login(UserName, Password)
        print 'User Credentials Authenticated'
        Details = server.sendmail(UserName, RecipientAddress, Data)
        server.quit()

    except smtplib.SMTPAuthenticationError:
        print 'User Name / Password Incorrect. Please check details again'
    except smtplib.SMTPSenderRefused:
        print 'Sender Address is Incorrect'
    except smtplib.SMTPRecipientsRefused:
        print 'Recipient Address is Incorrect'
    except smtplib.SMTPDataError:
        print 'Message Creation Incorrect'
    except smtplib.SMTPConnectError:
        print 'Connection to the Server refused'
    except smtplib.SMTPException:
        print 'SMTP Error'
    except:
        print 'Error Except SMTP But While Sending E Mail'

    if (Details == {}):
        print 'Mail Sent Succesfully'

        CreateFolder('Sent')
        for file in ExcelFiles:
            shutil.copy2(file, 'Sent')
            UserDetails.deleteFile(file)

        print 'File Saved To Sent Folder'

        return True

    else:
        print 'Something Went Wrong While Sending The Mails'
        print Details
        return False
Exemplo n.º 11
0
import calendar, itertools, re, sys
import IssueDetails, WorkDetails, UserDetails
import JiraReport
from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool
from prettytable import PrettyTable

# "main" code
options, conn, users = None, None, None
report = JiraReport.JiraReport()
conn = report.getConn()

# Handle configuration, input parsing, simple help messages
options = report.reportSettings(sys.argv[1:])

userDetails = UserDetails.UserDetails(jira=conn)

if options['group'] == None:
    # Run report for a single user.
    users = []
    users.append(options['user'])
else:
    # Run report for a group of users.
    users = []
    for u in userDetails.getUsersInGroup(group=options['group']):
        users.append(u)

issueDetails = IssueDetails.IssueDetails(
    month=options['month'],
    year=options['year'],
    user=None,
Exemplo n.º 12
0
def SendEmail(RecipientAddress):
	
	UserName,Password=UserDetails.ObtainUserCredentials()
	ExcelFiles,Subject=CreateSubjectLine()
	
	if(ExcelFiles==[] or Subject==''):
		print 'No Excel Files Found'
		return False
	
	print 'Subject Line Generated'
	
	msg = MIMEMultipart()
 
	msg['From'] = UserName
	msg['To'] = ",".join(RecipientAddress)
	msg['Subject'] = Subject
	
	print 'Recipient Address List Ready'
 
	body = " "
 
	msg.attach(MIMEText(body, 'plain'))
 
	for file in ExcelFiles:
		attachment = open(file, "rb")

		part = MIMEBase('application', 'octet-stream')
		part.set_payload((attachment).read())
		encoders.encode_base64(part)
		part.add_header('Content-Disposition', "attachment; filename= %s" % file)
 
		msg.attach(part)
		attachment.close()
		
	Data=msg.as_string()
	
	print 'Attachment Ready'
	
	try:
		server = smtplib.SMTP('smtp.rediffmail.com', 25)
		server.starttls()
		server.ehlo()
		server.esmtp_features["auth"] = "LOGIN PLAIN"
		server.login(UserName, Password)
		print 'User Credentials Authenticated'
		Details=server.sendmail(UserName, RecipientAddress, Data)
		server.quit()
		
	except smtplib.SMTPAuthenticationError:
		print 'User Name / Password Incorrect. Please check details again'
	except smtplib.SMTPSenderRefused:
		print 'Sender Address is Incorrect'
	except smtplib.SMTPRecipientsRefused:
		print 'Recipient Address is Incorrect'
	except smtplib.SMTPDataError:
		print 'Message Creation Incorrect'
	except smtplib.SMTPConnectError:
		print 'Connection to the Server refused'
	except smtplib.SMTPException:
		print 'SMTP Error'
	except:
		print 'Error Except SMTP But While Sending E Mail'
	
	if (Details=={}):
		print 'Mail Sent Succesfully'
		
		CreateFolder('Sent')
		for file in ExcelFiles:
			shutil.copy2(file, 'Sent')
			UserDetails.deleteFile(file)
		
		print 'File Saved To Sent Folder'
		
		return True
		
	else:
		print 'Something Went Wrong While Sending The Mails'
		print Details
		return False