def dashboard_bugs_duration(plan, fact, auto_open, priorities, labels, creators, repository, citrix_token, local_user): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data_dao = dc.get_issue_sqllite(query=None, expand=None) for priority in priorities: dashboard = BugsDurationDashboard() dashboard.dashboard_name = 'Bugs Life Cycle for ' dashboard.items_on_chart = 10 dashboard.min_item_tail = 5 dashboard.plan = plan dashboard.fact = fact dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.priority = priority.strip() dashboard.creators = creators dashboard.labels = labels dashboard.prepare(data=data_dao) dashboard.export_to_plot()
def dashboard_yota_burndown(auto_open, repository, mssql_query_file, dashboard_type, citrix_token, local_user, labels, dashboard_name, start_date, end_date): dc = DataController() data_spent = dc.get_issues_mssql(mssql_query_file=mssql_query_file[0]) data_original = dc.get_issues_mssql( mssql_query_file=mssql_query_file[1]) dashboard = None for dt in dashboard_type: if dt == 'TOTAL': dashboard = YotaBurndownDashboard() elif dt == 'DOMAIN': dashboard = YotaDomainBurndownDashboard() elif dt == 'WORKS': dashboard = YotaWorksBurndownDashboard() dashboard.dashboard_name = dashboard_name dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.labels = labels dashboard.start_date = datetime.datetime.strptime( start_date, '%d.%m.%y').date() dashboard.end_date = { scope: datetime.datetime.strptime(date, '%d.%m.%y').date() for scope, date in end_date.items() } dashboard.multi_prepare(data_spent=data_spent, data_original=data_original) dashboard.export_to_plot()
def dashboard_feature_progress(self, plan, fact, details): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data = dc.get_pandas_issues(query=None, expand=None) df1 = data[(data.issuetype == "Epic") | (data.issuetype == "Documentation")] df2 = df1[df1["labels"].str.contains(pat="num")] d = df2['labels'].to_dict() fl = get_feature_list(d) # fg = get_group_list(d) fser = get_feature_series(fl, 2) dashboard = FeatureProgressDashboard() for i in range(0, len(fser)): dashboard.dashboard_name = 'Feature F-{0}'.format( i) # str(i).zfill(1) dashboard.filter_list = ['num{0}'.format(i)] dashboard.items_on_chart = 40 dashboard.min_item_tail = 6 dashboard.plan = plan dashboard.fact = fact dashboard.details = details dashboard.prepare(data=data) dashboard.export_to_plot()
def update(query, start, jira_url, jira_name): """update data in cache""" mng = DataController() mng.update_cache_from_jira(query=query, start=start, url=jira_url, jira_name=jira_name)
def get_daily_result(fundcode, amount): print('获取' + fundcode + '净值...') fundgetter = FundGetter(fundcode) today_fund_price, extent = fundgetter.get_price() dc = DataController() yesterday_fund_price = float(dc.get_fund_price(fundcode)) result = extent * float(amount) return today_fund_price, result
def dashboard_reference_implementation(self): dc = DataController() data = dc.get_pandas_issues(query=None) options = cc_klass().read_dashboards_config() data_path = options[config_controller.FEATURE_PROGRESS_FILE] data_dict = data.to_dict(orient='index') serializable_data_dict = iu.serialize(data_dict) DashboardController.save_to_json(data=serializable_data_dict, file_path=data_path)
def __init__(self, update_server): self.temperature_controller = TemperatureController(set_temperature=20, mode=Mode.COOLER) self.sensor_controller = SensorController() self.mqtt_controller = DataController() self.user_interface = UserInterface() self.unit_controller = UnitController() self.update_server = update_server self.command_subscriber = CommandSubscriber("192.168.3.2", self.handle_command) self.current_display_data = None
def dashbord_issue_detail(self, key, field_mode, export, jira_url): dc = DataController() issue = dc.get_issue(key=key, jira_url=jira_url) dashboard = IssueDetailDashboard() dashboard.dashboard_name = "{0}".format(key) dashboard.items_on_chart = 30 dashboard.min_item_tail = 6 if field_mode is not None: dashboard.field_mode = field_mode dashboard.prepare(data=issue) dashboard.export_to_file(export_type=export)
def dashboard_iot(auto_open, repository, mssql_query_file, citrix_token, local_user): dc = DataController() data = dc.get_issues_mssql(mssql_query_file=mssql_query_file) dashboard = IotDashboard() dashboard.dashboard_name = 'IoT Super Sprint 10' dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.prepare(data=data) dashboard.export_to_plot()
def dashboard_ba_work_distribution(auto_open, repository, mssql_query_file, citrix_token, local_user): dc = DataController() data = dc.get_issues_mssql(mssql_query_file=mssql_query_file) dashboard = BaWorkDistributionDashboard() dashboard.dashboard_name = 'Business Analysts work distribution' dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.prepare(data=data) dashboard.export_to_plot()
def dashboard_all_bugs(auto_open, repository, mssql_query_file, citrix_token, local_user): dc = DataController() data = dc.get_issues_mssql(mssql_query_file=mssql_query_file) dashboard = AllBugsDashboard() dashboard.dashboard_name = 'All bugs in BSSBox and Domains projects' dashboard.repository = repository dashboard.auto_open = auto_open dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.prepare(data=data) dashboard.export_to_plot()
def dashboard_bssbox_bugs_tracking(auto_open, repository, mssql_query_file, citrix_token, local_user, dashboard_name): dc = DataController() data = dc.get_issues_mssql(mssql_query_file=mssql_query_file) dashboard = BssboxBugsTrackingDashboard() dashboard.dashboard_name = dashboard_name dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.prepare(data=data) dashboard.export_to_plot()
def setUp(self): dir = os.path.dirname(__file__) self.data_controller = DataController() self.data_controller.read_settings(dir + "\settings.yaml") self.login = self.data_controller.config["login"] self.password = self.data_controller.config["password"] self.output_dir = dir + self.data_controller.config["output_path"] browser_factory = BrowserFactory(self.data_controller) self.driver = browser_factory.driver # Implicit wait 30 seconds self.driver.implicitly_wait(30) self.driver.maximize_window() self.driver.get(self.data_controller.config["url"])
def dashboard_heatmap(self): dc = DataController() data = dc.get_pandas_issues(query=None, expand='') df1 = data[data.issuetype == "Epic"] df2 = df1[df1["labels"].str.contains(pat="num")] d = df2['labels'].to_dict() fl = get_feature_list(d) fgl = get_feature_series(fl, 3) dashboard = FeatureHeatmapDashboard() for i in range(0, 1): dashboard.dashboard_name = i # str(i).zfill(1) dashboard.prepare(data=df2) dashboard.export_to_plot()
def dashboard_sprint_info(auto_open, repository, mssql_query_file, dashboard_type, citrix_token, local_user, dashboard_name, end_date): dc = DataController() data = dc.get_issues_mssql(mssql_query_file=mssql_query_file) for dt in dashboard_type: dashboard = SprintInfoDashboard( ) if dt == 'DOMAIN' else FeatureInfoDashboard() dashboard.dashboard_name = dashboard_name dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.end_date = datetime.datetime.strptime( end_date, '%d.%m.%y').date() dashboard.prepare(data=data) dashboard.export_to_plot()
def dashboard_bugs_progress(plan, fact, auto_open, repository, citrix_token, local_user): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data_dao = dc.get_issue_sqllite(query=None, expand=None) dashboard = BugsProgressDashboard() dashboard.dashboard_name = 'BSSBox bugs progress' dashboard.items_on_chart = 20 dashboard.min_item_tail = 5 dashboard.plan = plan dashboard.fact = fact dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.prepare(data=data_dao) dashboard.export_to_plot()
def dashboard_feature_domain_progress(self, plan, fact, details, projects, fixversion, auto_open, dashboard_type, dashboard_format, sprint, components, upload_to_file, labels): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data_dao = dc.get_issue_sqllite(query=None, expand=None, upload_to_file=upload_to_file) project_list = projects #["BSSPAY", "BSSUFM", "BSSBFAM", "BSSLIS"] for project in project_list: dashboard = FeatureProgressDomainDashboard() dashboard.dashboard_name = 'All features in ' + (fixversion if project == "" else project) + \ (('('+components + ')') if components != "" else "") + \ ((' ' + sprint) if sprint != "" else "") dashboard.filter_list = [""] dashboard.items_on_chart = 40 dashboard.min_item_tail = 6 dashboard.plan = plan dashboard.fact = fact dashboard.details = details dashboard.auto_open = auto_open dashboard.project = project dashboard.fixversion = fixversion dashboard.dashboard_type = dashboard_type dashboard.dashboard_format = dashboard_format dashboard.sprint = sprint dashboard.components = components dashboard.labels = labels dashboard.prepare(data=data_dao) #lopen_list, ldev_list, lclose_list, lname_list = data_dao.get_sum_by_projects(dashboard.project, "", # fixversion) #for val in lname_list: # dashboard.open_list, dashboard.dev_list, dashboard.close_list, dashboard.name_list dashboard.export_to_plot()
class DataModel(IDataModel): "A Subject (a.k.a Observable)" def __init__(self): self._observers = {} self._counter = 0 # subscribing to an external hypothetical data controller self._data_controller = DataController() self._data_controller.subscribe(self) def subscribe(self, observer): self._counter = self._counter + 1 self._observers[self._counter] = observer return self._counter def unsubscribe(self, observer_id): self._observers.pop(observer_id) def notify(self, data): for observer in self._observers: self._observers[observer].notify(data)
def dashboard_sprint_burndown(auto_open, repository, mssql_query_file, dashboard_type, citrix_token, local_user, dashboard_name, start_date, end_date): dc = DataController() data_spent = dc.get_issues_mssql(mssql_query_file=mssql_query_file[0]) data_original = dc.get_issues_mssql( mssql_query_file=mssql_query_file[1]) for dt in dashboard_type: dashboard = SprintBurndownDashboard( ) if dt == 'SPRINT' else DomainBurndownDashboard() dashboard.dashboard_name = dashboard_name dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.start_date = datetime.datetime.strptime( start_date, '%d.%m.%y').date() dashboard.end_date = datetime.datetime.strptime( end_date, '%d.%m.%y').date() dashboard.multi_prepare(data_spent=data_spent, data_original=data_original) dashboard.export_to_plot()
def dashboard_feature_group_progress(self, plan, fact, details): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data = dc.get_pandas_issues(query=None, expand=None) dashboard = FeatureProgressDashboard() #Dashbord parameters #filter to search epics (feature group) fg_list = FEATURE_GROUP_LIST.split(sep=';') dashboard.filter_list = fg_list dashboard.dashboard_name = "Feature Group Dashboard" dashboard.items_on_chart = 30 dashboard.min_item_tail = 6 dashboard.plan = plan dashboard.fact = fact dashboard.details = details dashboard.prepare(data=data) dashboard.export_to_plot()
def dashboard_arba_issues(plan, fact, auto_open, assignees, teams, details, repository, citrix_token, local_user): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data_dao = dc.get_issue_sqllite(query=None, expand=None) if details == 'issues': dashboard = ArbaIssuesDashboard() dashboard.dashboard_name = teams + ' issues tracking' dashboard.items_on_chart = 10 dashboard.min_item_tail = 5 dashboard.plan = plan dashboard.fact = fact dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.assignees = assignees dashboard.prepare(data=data_dao) dashboard.export_to_plot() elif details == 'review': dashboard = ArbaReviewDashboard() dashboard.dashboard_name = teams + ' review' dashboard.items_on_chart = 10 dashboard.min_item_tail = 5 dashboard.plan = plan dashboard.fact = fact dashboard.auto_open = auto_open dashboard.repository = repository dashboard.citrix_token = citrix_token dashboard.local_user = local_user dashboard.assignees = assignees dashboard.prepare(data=data_dao) dashboard.export_to_plot()
def dashboard_bugs(plan, fact, auto_open, priorities, projects, statuses, labels, repository): if not (plan and fact): raise ValueError('both of plan and fact parameters are false') dc = DataController() data_dao = dc.get_issue_sqllite(query=None, expand=None) for priority in priorities: dashboard = BugsDashboard() dashboard.dashboard_name = '{0}s in BSSBox'.format(priority.strip()) if labels == ''\ else 'Showstoppers in BSSBox' dashboard.items_on_chart = 10 dashboard.min_item_tail = 5 dashboard.plan = plan dashboard.fact = fact dashboard.priority = priority.strip() dashboard.projects = projects dashboard.statuses = statuses dashboard.labels = labels dashboard.repository = repository dashboard.auto_open = auto_open dashboard.prepare(data=data_dao) dashboard.export_to_plot()
def get_all(query=None): """update data in cache""" mng = DataController() mng.get_issues_by_query(query)
import shutil import pyforms import traceback import threading from pyforms import BaseWidget from pyforms.controls import ControlText from pyforms.controls import ControlButton from pyforms.controls import ControlCombo from pyforms.controls import ControlTextArea from pyforms.controls import ControlLabel from pyforms.controls import ControlTextArea from data_controller import DataController from fund_getter import FundGetter q1 = queue.Queue() lock = threading.Lock() dc = DataController() fg = FundGetter() class FundCalculatorGUI(BaseWidget): def __init__(self): super(FundCalculatorGUI, self).__init__('FundCalculatorGUI') self.daily_report = ControlLabel() self.current_fund = ControlLabel('Current Fund:') self.fund_code = ControlText('Fund Code:') self.fund_amount = ControlText('Fund Amount:') self.add_fund_button = ControlButton('Add Fund') self.add_fund_button.value = self.add_fund
class Thermostat(): def __init__(self, update_server): self.temperature_controller = TemperatureController(set_temperature=20, mode=Mode.COOLER) self.sensor_controller = SensorController() self.mqtt_controller = DataController() self.user_interface = UserInterface() self.unit_controller = UnitController() self.update_server = update_server self.command_subscriber = CommandSubscriber("192.168.3.2", self.handle_command) self.current_display_data = None def startup(self): pass def run(self): self.command_subscriber.subscribe() while True: current_temperature = self.sensor_controller.get_temperature() current_state = self.temperature_controller.handle_new_reading( current_temperature) current_humidity = self.sensor_controller.get_humidity() converted_data = self.unit_controller.convert({ "temperature": current_temperature, "set_temperature": self.temperature_controller.get_set_temperature(), "humidity": current_humidity, "mode": self.temperature_controller.get_mode(), "state": current_state }) self.mqtt_controller.publish_data(converted_data) self.update_server(converted_data) self.command_subscriber.command_loop() self.current_display_data = converted_data time.sleep(1) def handle_command(self, command): command_type = command.get('command') if command_type == "SET_TEMPERATURE": self.temperature_controller.update_set_temperature( self.unit_controller.convert_incomming( command['data']['temperature'])) elif command_type == "SET_MODE": self.temperature_controller.set_mode(Mode(command['data']['mode'])) def update_set_temperature(self, set_temperature): converted_temp = UnitController.convert_f_to_c(set_temperature) self.temperature_controller.update_set_temperature(converted_temp) self.update_server({ "temperature": self.current_display_data.get('temperature'), "set_temperature": set_temperature, "humidity": self.current_display_data.get('humidity'), "mode": self.temperature_controller.get_mode(), "state": self.current_display_data.get('state') }) def shutdown(self): print('Shutting Down') self.temperature_controller.shutdown()
def __init__(self): self._observers = {} self._counter = 0 # subscribing to an external hypothetical data controller self._data_controller = DataController() self._data_controller.subscribe(self)
today_fund_price, extent = fundgetter.get_price() dc = DataController() yesterday_fund_price = float(dc.get_fund_price(fundcode)) result = extent * float(amount) return today_fund_price, result def get_time(): CurrentHour = int(time.strftime('%H', time.localtime(time.time()))) CurrentMin = int(time.strftime('%M', time.localtime(time.time()))) CurrentTime = CurrentHour + CurrentMin / 100 CurrentWeek = int(time.strftime('%w', time.localtime(time.time()))) return CurrentTime, CurrentWeek # itchat.auto_login(hotReload=True) dc = DataController() dc.create_table() if dc.if_data_need_to_init(len(funds)): print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '表中没有数据,需要初始化数据') dc.clean_data() i = 0 for fund in funds: dc.init_data(funds[i]) i += 1 else: print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '表中已经存在数据,无需初始化,表中的基金份额为:') for fund in funds: print(fund + '的份额为: ' + str(round(dc.get_fund_amount(fund), 2))) y_or_n = input(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '是否需要重新确定份额?Y/N') if y_or_n == 'Y' or y_or_n == 'y': dc.clean_data()
pygame.draw.rect(screen, pygame.Color(0, 180, 0), (100, self.height - 70, 400, 50)) screen.blit( menu, (self.width // 2 - menu.get_width() // 2, self.height - 60)) else: self.render() self.game_over_delay -= 1 blackout = pygame.Surface((self.width, self.height)) blackout.set_alpha( math.floor(255 - 255 * self.game_over_delay / self.game_over_delay_start)) screen.blit(blackout, (0, 0)) dataController = DataController() dataController.load_personal_data() dataController.load_ships_data() pygame.init() pygame.display.set_caption('') clock = pygame.time.Clock() size = width, height = 600, 800 screen = pygame.display.set_mode(size) running = True gameState = {'menu': True, 'over': False, 'isPlaying': False} music_controller.play_menu() menu = Menu(size) game = Game(size) while running: if gameState['menu']: menu.handleEvents(pygame.event.get())
"Observer Design Pattern Concept" from data_model import DataModel from data_controller import DataController from pie_graph_view import PieGraphView from bar_graph_view import BarGraphView from table_view import TableView # A local data view that the hypothetical external controller updates DATA_MODEL = DataModel() # Add some visualisation that use the dataview PIE_GRAPH_VIEW = PieGraphView(DATA_MODEL) BAR_GRAPH_VIEW = BarGraphView(DATA_MODEL) TABLE_VIEW = TableView(DATA_MODEL) # A hypothetical data controller running in a different process DATA_CONTROLLER = DataController() # The hypothetical external data controller updates some data DATA_CONTROLLER.notify([1, 2, 3]) # Client now removes a local BAR_GRAPH BAR_GRAPH_VIEW.delete() # The hypothetical external data controller updates the data again DATA_CONTROLLER.notify([4, 5, 6])
def initialize_cache(query, url, jira_name): """update data in cache""" mng = DataController() mng.initialize_cache_from_jira(query=query, url=url, jira_name=jira_name)