コード例 #1
0
def get_departments():
    with codecs.open('departments/departments.txt', 'r', 'utf-8') as f:
        departments = f.readlines()
    departments = [line.strip().split('::') for line in departments]
    return [
        Department(department[0], department[1])
        if len(department) > 1 else Department(department[0], None)
        for department in departments
    ]
コード例 #2
0
def updateDepartment(department_id):
    if not request.json or not 'name' in request.json or not 'id' in request.json:
        return jsonify({"result": False, "msg": "Failed to Update Department"})

    department = Department(request.json['name'], request.json['id'])

    result = Department.updateDepartment(department, mysql)

    if result is True:
        return jsonify({
            "result": True,
            "msg": "Successfully Updated Department!"
        })

    return jsonify({"result": False, "msg": "Failed to Update Department!"})
コード例 #3
0
	def post(self):
		department_name = self.request.get('department_name')
		department_id = int(self.request.get('department_id') or 0)

		if department_id:
			department = Department.get_by_id(department_id)
			department.department_name = department_name
			department.put()
		else:
			department = Department(
				id = department_id,
				department_name = department_name
			)
			department.put()
		self.redirectto('/department')
コード例 #4
0
def addDepartment():
    if not request.json or not 'name' in request.json:
        return jsonify({"result": False, "msg": "Failed to Add Department"})

    department = Department(request.json['name'])

    result = Department.addDepartment(department, mysql)

    if result is True:
        return jsonify({
            "result": True,
            "msg": "Department Added Successfully!"
        })

    return jsonify({"result": False, "msg": "Failed to Add Department!"})
コード例 #5
0
ファイル: load_dept.py プロジェクト: redknitin/excel_mani
def load_from_sheet(a_sheet):
    AssetColl = []
    for rowidx in range(a_sheet.nrows):
        if a_sheet.cell(rowidx, 1).value == 'Department' or \
                        a_sheet.cell(rowidx, 1).value == 'Department Code' or \
                        a_sheet.cell(rowidx, 1).value == 'nvarchar' or \
                        a_sheet.cell(rowidx, 1).value == '' or \
                        a_sheet.cell(rowidx, 1).value == 15.0:
            continue

        iterAsset = Department()

        iterAsset.department_code = a_sheet.cell(rowidx, 1).value
        iterAsset.description = a_sheet.cell(rowidx, 2).value
        iterAsset.department_type = a_sheet.cell(rowidx, 3).value
        iterAsset.default_store = a_sheet.cell(rowidx, 4).value

        AssetColl.append(iterAsset)
    return AssetColl
コード例 #6
0
def deleteDepartment(department_id):
    result = Department.deleteDepartment(department_id, mysql)

    if result is True:
        return jsonify({
            "result": True,
            "msg": "Successfully Deleted Department!"
        })

    return jsonify({"result": False, "msg": "Failed to Delete Department!"})
コード例 #7
0
def getDepartment(department_id):
    department = Department.getDepartment(department_id, mysql)

    if (department == None):
        return jsonify({"department": None, "msg": "Department Not Found"})

    return jsonify({
        "department": department,
        "msg": "Department Found Successfully!"
    })
コード例 #8
0
def scrapeDepartment():
    print("*************** Scraping Departments *********************")
    url = 'https://www.dal.ca/academics/faculties.html'
    soup = get_soup(url)
    main_div = soup.find_all("div", class_="expandingSubsection section")
    d_list = list()

    for child in main_div:
        a_tags = child.find_all("a")
        for a_tag in a_tags:
            txt = a_tag.get_text().strip()
            link = a_tag.get('href')
            d_list.append(Department(txt, link))
        pass
    generate_id(d_list)
    XmlList().from_list(d_list).save("department.xml")
コード例 #9
0
    def getDepartmentByID(self, info):
        departmentID = info['departmentID']
        try:
            query = db.session.query(Department).filter(
                Department.departmentID == departmentID)
            result = query.first()
            dataResult = {}
            dataResult.update(Department.generate(o=result))
            return (True, dataResult)

        except Exception as e:
            print e
            traceback.print_exc()
            errorInfo = ErrorInfo['TENDER_02']
            errorInfo['detail'] = str(e)
            db.session.rollback()
            return (False, errorInfo)
コード例 #10
0
	def get(self):
		faculties = db.GqlQuery("SELECT * FROM Faculty")
		departments = db.GqlQuery("SELECT * FROM Department")
		# for faculty  in faculties:
		# 	# found = False
		# 	for department in departments:
		# 		if faculty.department == department.key().id():
		# 			# found = True
		# 			# faculty.department = department.department_name
		# 			# faculty['department'] = department.department_name
		# 			break
		f = []
		for faculty in faculties:
			f.append({
				'id': faculty.key().name(),
				'faculty_name': faculty.faculty_name,
				'department_id': faculty.department,
				'department_name': Department.get_by_id(faculty.department).department_name
			})
		self.render("faculty.html",{'faculties':f, 'departments':departments})
コード例 #11
0
    def createDepartment(self, info):
        departmentName = info['departmentName'].strip()

        departmentID = self.generateID(departmentName)
        now = datetime.now()
        try:
            (status, reason) = self.__dupCheck(info=info)
            if status is not True:
                return (False, ErrorInfo['TENDER_46'])
            department = Department(departmentID=departmentID,
                                    departmentName=departmentName,
                                    createTime=now)
            db.session.add(department)
            db.session.commit()
            return (True, departmentID)
        except Exception as e:
            print e
            traceback.print_exc()
            errorInfo = ErrorInfo['TENDER_02']
            errorInfo['detail'] = str(e)
            db.session.rollback()
            return (False, errorInfo)
コード例 #12
0
    def get(self):
        teachers = db.GqlQuery("Select * from Teacher")
        departments = db.GqlQuery("Select * from Department")
        # class_courses = db.GqlQuery("Select * from ClassCourse")

        r = []
        for teacher in teachers:
            r.append(
                {
                    "id": teacher.key().id(),
                    "teacher_name": teacher.teacher_name,
                    "department_id": teacher.department,
                    "department_name": Department.get_by_id(teacher.department).department_name,
                    "teaching_time": teacher.teaching_time,
                }
            )
        self.render(
            "teacher.html",
            {
                "teachers": r,
                "departments": departments,
                # 'class_courses': class_courses
            },
        )
コード例 #13
0
import requests
from bs4 import BeautifulSoup

from spider import build_url, analyse_department_page, get_department_topics, spider, get_url
from models.Department import Department
from tools.repo import get_departments
from tools.updates2html import updates2html

cfg = ConfigParser()
cfg.read(os.path.abspath('.') + '\config.ini')
print(cfg.sections())
smtp_server = cfg.get('email', 'smtp_server')
from_addr = cfg.get('email', 'from_addr')
password = cfg.get('email', 'password')
print(smtp_server)
print(from_addr)
print(password)

cookies = cfg.items('douban_cookie')
print(dict(cookies))

print(get_departments())
url = build_url('滨兴小区', 0)
print(BeautifulSoup(get_url(url).content, 'html.parser').get_text())
print(BeautifulSoup(get_url(url).content, 'html.parser').get_text())
print(analyse_department_page(requests.get(url).content))
print(get_department_topics(Department('白金海岸', '2018-06-05 19:18:53')))
res = spider(get_departments())
print(updates2html(res))
print(os.path.abspath('.') + '\config.ini')
コード例 #14
0
 def __generateDepartment(self, o):
     res = {}
     res.update(Department.generate(o=o))
     return res
コード例 #15
0
def getAllDepartments():
    # Retrieve all the Employees from the Database
    return jsonify({"departments": Department.getAllDepartments(mysql)})