示例#1
0
def Triangle_output(a, b, c):
    Triangle_input.Triangle_input_a(a)
    Triangle_input.Triangle_input_b(b)
    Triangle_input.Triangle_input_c(c)

    num = Triangle_input.num
    test_num = Triangle_input.test_num
    if compare(a) == "请输入正整数或正小数" or compare(b) == "请输入正整数或正小数" or compare(
            c) == "请输入正整数或正小数":
        # print(num)
        print("您输入的三个值分别为%s,%s,%s" % (a, b, c))
        print("您输入的三个值不符合要求:请输入正整数或正小数")

        # 打印日志消息
        logger().info('输入不符合正整数或正小数')

        return "输入值错误"

    else:
        print("您输入的三个值分别为%s,%s,%s" % (a, b, c))
        print("您输入的三个值组合结果为:")

        result = Triangle.Triangle_PK(num['a'], num['b'], num['c'])

        # 打印日志消息
        logger().info('判断成功返回判断结果:' + result)
        return result


# a = input("输入组成三角形的第一个数:")
# b = input("输入组成三角形的第二个数:")
# c = input("输入组成三角形的第三个数:")
# Triangle_output(a,b,c)
示例#2
0
    def InsertPlacementDetails(self,mydb,mycursor):
        """insertion of placement details of the student into the placement details dimension table."""
        try:        
            filename = 'C:\\Users\\mohan\\Desktop\\csv\\dimension\\company_dim.csv'
            with open(filename,'r') as fr:
                for line in fr.readlines():
                    col_value = line.replace('\n','').split(',')
                    insert_query = ("insert into placement_details values('{}','{}','{}','{}','{}','{}')"
								.format(col_value[0],col_value[1], col_value[2], col_value[3], datetime.now(), col_value[4]))
                    mycursor.execute(insert_query)
            mydb.commit()
            l = logfile.logger()
            l.info("Values inserted into the placement_details table successfully!")
        except Exception as e:
            l = logfile.logger()
            l.info(e)
            print("Error:",e)
示例#3
0
def enricher(id):
    query = FlickrQuery(gconfig.flickrAPI,gconfig.flickrSecret)
    event = eventinfo(id)
    logger = logfile.logger(gconfig.logdir + '/%s.txt' % event.id)
    logger.info('query event information')
    if not event.succ:
        logger.info( "can not find such event" )
        return
    logger.info('query photos with machine tag')
    idlist = query.searchbyid(event.id)
    db = Download(gconfig.tmpdir + '/%s' % event.id)
    db.download(idlist)
    #query.outputlist(idlist, event.id, 'list/idlist_%s.txt' % event.id)
    logger.info('query photos with text info')
    titlelist = query.searchbytitle(event.title,event.stime,event.id)
    db.download(titlelist)
    #query.outputlist(titlelist,event.id, 'list/titlelist_%s.txt' % event.id)
    logger.info('query photos with geo info')
    geolist = query.searchbygeo(event.lat,event.lng,event.stime,event.id)
    db.download(geolist)
    #query.outputlist(geolist,event.id,'list/geolist_%s.txt' % event.id)

    logger.info('parsing features')    
    feature = getfeature()
    feature.run(gconfig.tmpdir + '/%s' % event.id)
    
    #trainfile = 'list/idlist_%s.txt' % event.id
    trainlist = []
    for url in idlist:
        fname = url.split('/')[-1]
        fname = gconfig.tmpdir + '/%s' % event.id + '/' + fname
        trainlist.append(fname.replace('.jpg','_ch.txt'))
        
    testlist = []
    for url in titlelist:
        fname = url.split('/')[-1]
        fname = gconfig.tmpdir + '/%s' % event.id + '/' + fname
        testlist.append(fname.replace('.jpg','_ch.txt'))

    logger.info('visual pruning')        
    myfilter = filter(trainlist,testlist)
    r = myfilter.filter()
    lst = []
    for idx in r:
        lst.append(testlist[idx])

    logger.info('refining')        
    myrefine = refine(event.id,lst)
    results = myrefine.refine()
    newresults = query.geturlbyid(results,titlelist)

    logger.info('output result')    
    query.OutputXML(event.id,idlist,titlelist,geolist,newresults)
    query.OutputHtml(event.id,idlist,titlelist,geolist,newresults)
    logger.info('event-finished')    
示例#4
0
 def CalenderDetails(self, mydb, mycursor):
     """Creation of dimension table for  calender details."""
     try:
         sql = '''create table if not exists calender_details(TIME_ID VARCHAR(5) NOT NULL PRIMARY KEY,
                     HOLIDAY DATE,
                     HOLIDAY_START_DATE DATETIME,
                     HOLIDAY_END_DATE   DATETIME)'''
         #mycursor.execute("drop table calender_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Calender_Details created!")
     except Exception as e:
         print("Error:", e)
示例#5
0
 def DepartmentDetails(self, mydb, mycursor):
     """Creation of dimension table for  department details."""
     try:
         sql = '''create table if not exists department_details(DEP_ID VARCHAR(9) NOT NULL PRIMARY KEY,
                     DEP_NAME VARCHAR(50),
                     DEP_START_DATE DATETIME,
                     DEP_END_DATE   DATETIME)'''
         #mycursor.execute("drop table department_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Dep_Details created!")
     except Exception as e:
         print("Error:", e)
示例#6
0
 def CourseDetails(self, mydb, mycursor):
     """Creation of dimension table for course details."""
     try:
         sql = '''create table if not exists course_details(COURSE_ID VARCHAR(9) NOT NULL PRIMARY KEY,
                     COURSE_NAME VARCHAR(20),
                     COURSE_START_DATE DATETIME,
                     COURSE_END_DATE   DATETIME)'''
         #mycursor.execute("drop table course_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Course_Details created!")
     except Exception as e:
         print("Error:", e)
示例#7
0
 def GradeDetails(self, mydb, mycursor):
     """Creation of dimension table for grade details."""
     try:
         sql = '''create table if not exists grade_details(GRADE_ID CHAR(2) NOT NULL PRIMARY KEY,
                     GRADE_DESCRIPTION    CHAR(20),
                     GRADE_START_DATE DATETIME,
                     GRADE_END_DATE   DATETIME)'''
         #mycursor.execute("drop table grade_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Grade_Details created!")
     except Exception as e:
         print("Error:", e)
示例#8
0
 def createFpayment(self, mydb, mycursor):
     """Creation of fact table for payment."""
     try:
         sql='''create table if not exists FactPayment(STUDENT_ID BIGINT NOT NULL,
                  FEE_ID    VARCHAR(10)   NOT NULL,
                  PAYMENT_ID VARCHAR(9),
                  PAYMENT_FACT_START_DATE DATETIME,
                  PAYMENT_FACT_END_DATE   DATETIME)'''
         #mycursor.execute("drop table FactPayment")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("Fact : Payment created!")
     except Exception as e:
         print("Error:", e)
示例#9
0
 def PaymentDetails(self, mydb, mycursor):
     """Creation of dimension table for payment details."""
     try:
         sql = '''create table if not exists payment_details(FEE_ID VARCHAR(10) NOT NULL PRIMARY KEY,
                     FEES   BIGINT,
                     FEES_TYPE  VARCHAR(15),
                     PAYMENT_START_DATE DATETIME,
                     PAYMENT_END_DATE   DATETIME)'''
         #mycursor.execute("drop table payment_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Payment_Details created!")
     except Exception as e:
         print("Error:", e)
示例#10
0
 def insertSTUDENT_REFERENCE(self, mydb, mycursor):
     """insertion of student reference table which contains details of the student."""
     try:
         with open(r"C:\Users\k.a.ramasubramanian\Desktop\Training\git\DataModel\prod_data\reference\student_reference.csv") as data:
             for i in reader(data):
                 sql = "INSERT INTO STUDENT_REFERENCE VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
                 val = (i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],datetime.now(),i[9])
                 mycursor.execute(sql, val)
                 mydb.commit()
         print("No. of rows inserted:", mycursor.rowcount)
         l = logfile.logger()
         l.info("STUDENT_REFERENCE-RECORDS inserted")
         print("Rows Inserted")
     except Exception as e:
         print("Error:", e)
示例#11
0
 def StaffDetails(self, mydb, mycursor):
     """Creation of dimension table for  staff details."""
     try:
         sql = '''create table if not exists staff_details(STAFF_ID VARCHAR(9) NOT NULL PRIMARY KEY,
                     STAFF_NAME VARCHAR(25),
                     STAFF_DOJ   DATE,
                     STAFF_START_DATE DATETIME,
                     STAFF_END_DATE   DATETIME)'''
         #mycursor.execute("drop table staff_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Staff_Details created!")
     except Exception as e:
         print("Error:", e)
示例#12
0
 def ExamDetails(self, mydb, mycursor):
     """Creation of dimension table for exam details."""
     try:
         sql = '''create table if not exists exam_details(EXAM_ID INT NOT NULL PRIMARY KEY,
                     EXAM_TYPE   VARCHAR(3),
                     EXAM_DESCRIPTION    VARCHAR(15),
                     EXAM_START_DATE DATETIME,
                     EXAM_END_DATE   DATETIME)'''
         #mycursor.execute("drop table exam_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Exam_Details created!")
     except Exception as e:
         print("Error:", e)
示例#13
0
 def Degree(self, mydb, mycursor):
     """Creation of dimension table for degree."""
     try:
         sql = '''create table if not exists degree(DEGREE_ID BIGINT NOT NULL PRIMARY KEY,
                     DEGREE_TYPE   VARCHAR(5),
                     DURATION   INT,
                     DEGREE_START_DATE DATETIME,
                     DEGREE_END_DATE   DATETIME)'''
         #mycursor.execute("drop table degree")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Details created!")
     except Exception as e:
         print("Error:", e)
示例#14
0
 def insertFattendence(self,mydb, mycursor):
     """insertion of placement fact table which contains details of the student."""
     try:
         with open(r"C:\Users\k.a.ramasubramanian\Desktop\Training\git\DataModel\prod_data\fact\attendance_fact.csv") as data:
             for i in reader(data):
                 sql = "INSERT INTO factattendence VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
                 val = (i[0], i[1], i[2], i[3],i[4],i[5],datetime.now(), i[7])
                 mycursor.execute(sql,val)
                 mydb.commit()
         print("No. of rows inserted:", mycursor.rowcount)
         l = logfile.logger()
         l.info("FACT_STUDENT-RECORDS inserted")
         print("Rows Inserted")
     except Exception as e:
         print("Error:", e)
示例#15
0
 def PlacementDetails(self, mydb, mycursor):
     """Creation of dimension table for  placement details."""
     try:
         sql = '''create table if not exists placement_details(COMPANY_ID VARCHAR(9) NOT NULL PRIMARY KEY,
                     COMPANY_NAME    VARCHAR(15),
                     PLACEMENT_VENUE VARCHAR(50),
                     PLACEMENT_DATE  DATE,
                     PLACEMENT_START_DATE DATETIME,
                     PLACEMENT_END_DATE   DATETIME)'''
         #mycursor.execute("drop table placement_details")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("DIMENSION : Placement_Details created!")
     except Exception as e:
         print("Error:", e)
示例#16
0
def tables():
    """GETTING THE LIST OF TABLES"""
    try:
        del sys.path[:]
        sys.path.append(os.listdir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'files', 'ddl')))
        tables = []
        for i in sys.path:
            for j in i:
                table = "".join(j)
                table = table.split(".")[0]
                tables.append(table)
            return tables
    except Exception as e:
        logs = logfile.logger()
        logs.debug(repr(traceback.format_exception(*sys.exc_info())))
        return 1
示例#17
0
 def createFattendence(self, mydb, mycursor):
     """Creation of fact table for attendance."""
     try:
         sql='''create table if not exists FactAttendence(STUDENT_ID BIGINT NOT NULL,
                  TIME_ID    VARCHAR(5),
                  CURDATE    DATE,
                  COURSE_ID  VARCHAR(9),
                  STAFF_ID   VARCHAR(9),
                  ATTENDENCE VARCHAR(5),
                  ATTENDENCE_START_DATE DATETIME,
                  ATTENDENCE_END_DATE   DATETIME)'''
         #mycursor.execute("drop table FactAttendence")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("FACT : Attendence created!")
     except Exception as e:
         print("Error:", e)
示例#18
0
 def createFacademics(self, mydb, mycursor):
     """Creation of fact table for academics."""
     try:
         sql='''create table if not exists FactAcademics(STUDENT_ID BIGINT NOT NULL,
                  DEGREE_ID  BIGINT,
                  EXAM_ID    INT,
                  MARKS  INT,
                  COURSE_ID  VARCHAR(9),
                  GRADE_ID   CHAR(2),
                  ACADEMICS_START_DATE DATETIME,
                  ACADEMICS_END_DATE   DATETIME)'''
         #mycursor.execute("drop table FactAcademics")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("Fact : Academics created!")
     except Exception as e:
         print("Error:", e)
示例#19
0
    def __init__(self):
        """Connection with the database is established and the functions for table creation are invoked"""
        try:
            l = logfile.logger()
            mydb = connection.con()
            mycursor = mydb.cursor()
            self.createSTUDENT_REFERENCE(mydb, mycursor)
            self.createFpayment(mydb, mycursor)
            self.createFacademics(mydb, mycursor)
            self.createFstudent(mydb, mycursor)
            self.createFattendence(mydb, mycursor)
            self.createFplacement(mydb, mycursor)

            self.PaymentDetails(mydb, mycursor)
            self.Degree(mydb, mycursor)
            self.ExamDetails(mydb, mycursor)
            self.GradeDetails(mydb, mycursor)
            self.CourseDetails(mydb, mycursor)
            self.DepartmentDetails(mydb, mycursor)
            self.StaffDetails(mydb, mycursor)
            self.CalenderDetails(mydb, mycursor)
            self.PlacementDetails(mydb, mycursor)

            # self.insertSTUDENT_REFERENCE(mydb, mycursor)
            # self.insertFpayment(mydb,mycursor)
            # self.insertFacademics(mydb,mycursor)
            # self.insertFplacement(mydb,mycursor)
            # self.insertFstudent(mydb,mycursor)
            # self.insertFattendence(mydb,mycursor)
            
            # self.InsertPaymentDetails(mydb, mycursor)
            # self.InserDegree(mydb, mycursor)
            # self.InsertExamDetails(mydb, mycursor)
            # self.InsertGradeDetails(mydb, mycursor)
            # self.InsertCourseDetails(mydb, mycursor)
            # self.InsertDeptDetails(mydb, mycursor)
            # self.InsertStaffDetails(mydb, mycursor)
            # self.InsertCalendarDetails(mydb, mycursor)
            # self.InsertPlacementDetails(mydb, mycursor)
            
        except Exception as e:
            print("Error:",e)
示例#20
0
 def createSTUDENT_REFERENCE(self, mydb, mycursor):
     """Creation of student reference table which contains details of the student."""
     try:
         sql='''create table if not exists STUDENT_REFERENCE(STUDENT_ID BIGINT PRIMARY KEY NOT NULL,
                  NAME     VARCHAR(45)   NOT NULL,
                  DOB       DATE       NOT NULL,
                  GENDER    VARCHAR(10),
                  GUARDIAN_NAME  VARCHAR(45),
                  ADDRESS    VARCHAR(50),
                  PHONE_NO   BIGINT,
                  DOJ    DATE,
                  STUDENT_START_DATE DATETIME,
                  STUDENT_END_DATE   DATETIME)'''
         #mycursor.execute("drop table student_reference")
         mycursor.execute(sql)
         mydb.commit()
         l = logfile.logger()
         l.info("STUDENT_REFERENCE created!")
     except Exception as e:
         print("Error:", e)
示例#21
0
 def __init__(self,tables):
     """CONNECTION WITH THE DATABASE IS ESTABLISHED AND THE ATTRIBUTES, FUNCTIONS FOR TABLE CREATION ARE INVOKED"""
     self.obj2 = execution.execution()
     self.logs=logfile.logger()
     self.tables=tables
示例#22
0
 def __init__(self, table):
     """CLASS INITALIZATION"""
     self.obj2 = execution.execution()
     self.logs = logfile.logger()
     self.table = table