本文整理汇总了Python中MOSES类的典型用法代码示例。如果您正苦于以下问题:Python MOSES类的具体用法?Python MOSES怎么用?Python MOSES使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MOSES类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: computeProcessDates
def computeProcessDates(self):
#For each index:
for processing_date in self.process_dates:
processed_dates = self.getProcessedDates()
efficiency = None
cfm = None
gseo = None
fatals = None
status = None
relaxation = None
approval = None
stats = None
if self.canSkipThisDate(processing_date):
efficiency = self.result_dictionary[processing_date].get("Efficiency")
cfm = self.result_dictionary[processing_date].get("CFM")
gseo = self.result_dictionary[processing_date].get("GSEO")
fatals = self.result_dictionary[processing_date].get("Fatals")
status = self.result_dictionary[processing_date].get("Status")
relaxation = self.result_dictionary[processing_date].get("Relaxation")
approval = self.result_dictionary[processing_date].get("Approval")
if efficiency is None:
efficiency = MOSES.getEfficiencyFor(self.user_id, self.password, processing_date, category_tree=self.category_tree)
if (cfm is None) or (gseo is None) or (fatals is None):
cfm, gseo, fatals = MOSES.getCFMGSEOFor(self.user_id, self.password, processing_date)
if (status is None) or (relaxation is None) or (approval is None):
status, relaxation, approval = MOSES.checkWorkStatus(self.user_id, self.password, processing_date)
processing_dict_entry = {
processing_date:
{
"Efficiency": efficiency,
"Status":status,
"Relaxation": relaxation,
"Approval": approval,
"CFM": cfm,
"GSEO": gseo,
"Fatals": fatals,
}
}
self.result_dictionary.update(processing_dict_entry)
self.sendResultDictionary.emit(self.result_dictionary)
self.sendStatsAfterUpdatingIfNecessary()
#Flush the force_update list and the process_list.
for each_date in self.getProcessedDates():
if each_date in self.force_update_dates:
self.force_update_dates.remove(each_date)
if each_date in self.process_dates:
self.process_dates.remove(each_date)
self.process_dates.extend(list(reversed(sorted(set(self.queue)))))
#if len(self.process_dates)>0:
# print self.process_dates
self.queue = []
示例2: getQualityHistoricalDataMonth
def getQualityHistoricalDataMonth(query_date = None, months = None):
import calendar
if query_date is None:
query_date = datetime.date.today()
if months is None:
months = 2
months_list = [month for month in range(query_date.month+1)][1:][-months:]
print months_list
dates_lists = []
end_dates = []
cfm_average_list = []
gseo_average_list = []
user_id, password = MOSES.getBigbrotherCredentials()
for month in months_list:
year_ = query_date.year
start_date = datetime.date(year_, month, 1)
end_date = datetime.date(year_, month, calendar.monthrange(year_, month)[1])
dates = MOSES.getWorkingDatesBetween(user_id, password, start_date, end_date, mode="All")
dates.sort()
start_date = min(dates)
end_date = max(dates)
cfm_average = 100.00*MOSES.getAverageTeamCFMBetween(start_date, end_date, True)
gseo_average = 100.00*MOSES.getAverageTeamGSEOBetween(start_date, end_date, True)
cfm_average_list.append(cfm_average)
gseo_average_list.append(gseo_average)
end_dates.append(end_date)
return end_dates, cfm_average_list, gseo_average_list
示例3: getQualityHistoricalData
def getQualityHistoricalData(query_date = None, period = None):
if query_date is None:
query_date = datetime.date.today()
if period is None:
period = 5
group_size = 5
quantity = int(period/group_size)
#Get a list of lists containing group of working dates.
dates_lists = MOSES.getWorkingDatesLists(query_date, group_size=group_size, quantity=quantity)
#create two lists of average cfm and average gseo for all writers for these groups of dates.
#print dates_lists
cfm_average_list, gseo_average_list = [], []
end_dates = []
for date_set in dates_lists:
start_date = min(date_set)
end_date = max(date_set)
end_dates.append(end_date)
#print start_date, end_date
cfm_average = 100.00*MOSES.getAverageTeamCFMBetween(start_date, end_date, True)
gseo_average = 100.00*MOSES.getAverageTeamGSEOBetween(start_date, end_date, True)
#print cfm_average, gseo_average
cfm_average_list.append(cfm_average)
gseo_average_list.append(gseo_average)
#print cfm_average_list, gseo_average_list
return end_dates, cfm_average_list, gseo_average_list
示例4: updateResultsDictionaryForDate
def updateResultsDictionaryForDate(self, query_date):
previous_dictionary = self.result_dictionary.get(query_date)
efficiency = MOSES.getEfficiencyFor(self.user_id, self.password, query_date, category_tree=self.category_tree)
cfm, gseo, fatals = MOSES.getCFMGSEOFor(self.user_id, self.password, query_date)
updated_dict = {"Efficiency": efficiency, "CFM": cfm, "GSEO": gseo, "Fatals": fatals}
if previous_dictionary is not None:
previous_dictionary.update(updated_dict)
else:
self.result_dictionary[query_date] = updated_dict
示例5: pullData
def pullData(self):
#print "Pulling data!"
self.pull_button.setEnabled(False)
self.piggybank_summarizer.setEnabled(False)
self.piggybank.showDataFrame(None)
message = "processing..."
self.status.setText(message)
self.alertMessage("Please Wait","Depending on the filters you have chosen, this step could take a second or a minute, though definitely not more than 60s. Please wait, and remember, <i>Roma die uno non aedificata est</i>.")
filters = self.getFilters()
data = MOSES.getPiggyBankWithFilters(self.user_id, self.password, filters)
if data is None:
message = "No data for selected filters."
self.status.setText(message)
self.alertMessage("No Data Available","There is no data pertaining to the selected filters. This could have occurred for several reasons:\n1. You may have selected too many filters which have no result, or\n2. You could have selected a date range between which there have been no articles.")
else:
if data.shape[0] <=0:
self.status.setText(message)
message = "No data for selected filters."
self.alertMessage("No Data Available","There is no data pertaining to the selected filters. This could have occurred for several reasons:\n1. You may have selected too many filters which have no result, or\n2. You could have selected a date range between which there have been no articles, or, simply\n3. There is no data.")
else:
self.piggybank_data = data
self.piggybank.showDataFrame(self.piggybank_data)
#populate the summary next.
self.piggybank_summarizer.setEnabled(True)
self.piggybank_summarizer.setPiggyBank(data)
message = "Retrieved %d rows of data pertaining to your filters."%(data.shape[0])
self.alertMessage("Retrieved Data",message)
self.status.setText(message)
#self.summarize()
self.pull_button.setEnabled(True)
示例6: createUI
def createUI(self, oink_widget_list):
self.label = QtGui.QLabel("Choose A Widget:")
self.combo_box_widgets = QtGui.QComboBox()
self.combo_box_widgets.addItems(oink_widget_list)
self.button = QtGui.QPushButton("Launch")
final_layout = QtGui.QHBoxLayout()
final_layout.addWidget(self.label)
final_layout.addWidget(self.combo_box_widgets)
final_layout.addWidget(self.button)
final_page = QtGui.QWidget()
final_page.setLayout(final_layout)
self.progress_bar = ProgressBar()
self.message = QtGui.QLabel("Loading.....")
loading_layout = QtGui.QVBoxLayout()
loading_layout.addWidget(self.progress_bar)
loading_layout.addWidget(self.message)
loading_page = QtGui.QWidget()
loading_page.setLayout(loading_layout)
self.stacked_widget = QtGui.QStackedWidget()
self.stacked_widget.addWidget(final_page)
self.stacked_widget.addWidget(loading_page)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.stacked_widget)
layout.addWidget(Taunter())
self.setLayout(layout)
self.setWindowTitle("OINK Widget Chooser")
icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
self.show()
示例7: __init__
def __init__(self, user_id, password, start_date, end_date = None, query_dict = None, category_tree = None, parent = None):
super(PiggyBanker, self).__init__(parent)
self.mutex = QtCore.QMutex()
self.condition = QtCore.QWaitCondition()
self.user_id = user_id
self.password = password
self.sleeper = 10
self.start_date = start_date
if query_dict is None:
#get all data for a writer between dates if only dates are given.
self.query_dict = {"WriterID": self.user_id}
else:
#If some query dictionary is supplied, get all data corresponding to that.
self.query_dict = query_dict
if end_date is None:
self.end_date = self.start_date
else:
self.end_date = end_date
if category_tree is None:
self.category_tree = MOSES.getCategoryTree(self.user_id, self.password)
else:
self.category_tree = category_tree
if not self.isRunning():
self.start(QtCore.QThread.LowPriority)
示例8: createUI
def createUI(self):
path_to_image = os.path.join(MOSES.getPathToImages(), "OINK.png")
self.image = ImageLabel(path_to_image, 800, 566)
#self.sharingan = SharinganButton()
self.progress_bar = ProgressBar()
self.message = QtGui.QLabel("Not all those who wander are lost....")
layout = QtGui.QVBoxLayout()
layout.addWidget(self.image)
layout.addWidget(self.progress_bar)
layout.addWidget(self.message)
layout.addWidget(Taunter())
self.setLayout(layout)
self.setWindowTitle("Bulk Buster: The OINK Preloader Screen")
icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
self.show()
示例9: buildWBR
def buildWBR(self):
self.build_wbr_button.setEnabled(False)
self.alertMessage("Please Wait","This could take a while.")
wbr = MOSES.getWBR(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.category_tree)
self.wbr_report.showDataFrame(wbr)
self.wbr_report.adjustToColumns()
self.build_wbr_button.setEnabled(True)
self.alertMessage("Success","Successfully Pulled the WBR")
示例10: applyFilters
def applyFilters(self):
self.leave_table.showDataFrame(None)
selected_employee_ids = [list(self.employees_list[self.employees_list["Name"] == x]["Employee ID"])[0] for x in self.employees_selection_box.getCheckedItems()]
if len(selected_employee_ids)<=0:
self.alertMessage("No Employees Selected","Select at least one employee!")
else:
filter_dict = {
"Dates": [self.start_date.date().toPyDate(), self.end_date.date().toPyDate()],
"Employee IDs": selected_employee_ids
}
time_diff = (filter_dict["Dates"][1] - filter_dict["Dates"][0])
if datetime.timedelta(days=5) < time_diff < datetime.timedelta(days=30):
self.alertMessage("Please Wait","The work calendar is being refreshed. This may take a while since you've selected over a week's worth of data.")
elif time_diff >= datetime.timedelta(days=30):
self.alertMessage("Please Wait","The work calendar is being refreshed. This will take quite some time longer than usual since you've selected a date range wider than or equal to 30 days.")
self.work_calendar = MOSES.getWorkCalendarFor(self.user_id, self.password, filter_dict)
self.alertMessage("Success","Retrieved the Work Calendar")
yellow = QtGui.QColor(200,200,0)
green = QtGui.QColor(0,153,0)
red = QtGui.QColor(170,0,0)
highlight_rules = [
{
"Columns": ["Status","Approval"],
"Values": ["Leave","Approved"],
"Color":green
},
{
"Columns": ["Status","Approval"],
"Values": ["Leave","Pending"],
"Color": yellow
},
{
"Columns": ["Status","Approval"],
"Values": ["Leave","Rejected"],
"Color": red
},
{
"Columns": ["Relaxation","Approval"],
"Values": [[0.01,1.00],"Approved"],
"Color": green
},
{
"Columns": ["Relaxation","Approval"],
"Values": [[0.01,1.00],"Pending"],
"Color": yellow
},
{
"Columns": ["Relaxation","Approval"],
"Values": [[0.01,1.00],"Rejected"],
"Color": red
}
]
self.leave_table.showDataFrame(self.work_calendar,highlight_rules)
self.leave_table.setSortingEnabled(False)
示例11: submit
def submit(self):
"""Leave Planner: Method to send the request to the work calendar table."""
startDate = self.start_date_edit.date().toPyDate()
endDate = self.end_date_edit.date().toPyDate()
status = str(self.statusComboBox.currentText())
relaxation = self.relaxationSpinBox.value() #Test this.
relaxation = float(relaxation)/100.00
comment = str(self.commentLineEdit.text())
dates_list = [startDate, endDate]
name = MOSES.getEmpName(self.user_id)
self.alertMessage("Please Wait","This process could take a while, and OINK will appear like it has hung. Rest assured that it's running in the background. Please be patient, %s."%name)
success = MOSES.askForModWorkCalendar(self.user_id, self.password, dates_list, status, relaxation, comment, name)
if success:
self.alertMessage("Success", "Your request has been submitted to the server. Ask your TL to approve the request.")
else:
self.alertMessage("Failed", "Your request could not be submitted. Ask your TL to manually mark your leaves in the server.")
示例12: populateWriters
def populateWriters(self):
self.writers_filter_box.clear()
start_date = self.start_date_edit.date().toPyDate()
end_date = self.end_date_edit.date().toPyDate()
self.writers_list = MOSES.getWritersList(self.user_id, self.password, start_date)
writers = list(set(self.writers_list["Name"]))
writers.sort()
self.writers_filter_box.addItems(writers)
示例13: initiate
def initiate(self):
self.start_date.setDate(datetime.date.today())
self.start_date.setMinimumDate(datetime.date(2015,1,1))
self.end_date.setDate(self.start_date.date())
self.end_date.setMinimumDate(self.start_date.date())
self.employees_list = MOSES.getEmployeesList(self.user_id, self.password, self.end_date.date().toPyDate())
self.employees_selection_box.clear()
self.employees_selection_box.addItems(sorted(list(self.employees_list["Name"])))
self.employees_selection_box.selectAll()
示例14: __init__
def __init__(self, user_id, password, category_tree=None, brands=None):
super(PiggyBankWithFilter, self).__init__()
self.user_id, self.password = user_id, password
if category_tree is not None:
self.category_tree = category_tree
else:
self.category_tree = MOSES.getCategoryTree(self.user_id, self.password)
if brands is None:
print "Pulling Brand list in PiggyBankWithFilter"
self.brands = MOSES.getBrandValues(self.user_id, self.password)
else:
self.brands = brands
self.createUI()
self.piggybank_data = []
self.mapEvents()
self.changePage()
self.populateBrand()
self.populateWriters()
self.show()
示例15: __init__
def __init__(self, user_id, password, category_tree, employees_list, brand_list):
super(Bacon, self).__init__()
self.user_id = user_id
self.password = password
self.category_tree = category_tree
self.employees_list = employees_list
self.brand_list = brand_list
self.current_processing_date = MOSES.getLastWorkingDate(self.user_id, self.password,datetime.date.today(),"All")
self.createUI()
self.mapEvents()