time.sleep(ticks) except KeyboardInterrupt: pass # kill seller thread seller_apple.kill() seller_samsung.kill() Save(seller_apple, object_type='seller') Save(seller_samsung, object_type='seller') # Plot the sales and expenditure trends plot(seller_apple) plot(seller_samsung) regression(seller_apple) regression(seller_samsung) for product in seller_apple.product_list: print('Total Profit Apple ' + product.name + ': ', seller_apple.my_profit(product)) for product in seller_samsung.product_list: print('Total Profit Samsung ' + product.name + ': ', seller_samsung.my_profit(product)) # Kill consumer threads for consumer in customers: consumer.kill() dataCenter.kill() utils.animate(dataCenter) # from market import Market # correlation_map = Market.correlation_map
# kill seller thread seller_apple.kill() seller_samsung.kill() seller_xiaomi.kill() seller_huawei.kill() # Plot the sales and expenditure trends plot(seller_apple) plot(seller_samsung) plot(seller_xiaomi) plot(seller_huawei) # print final results of profit of each seller print('\nResult:\n') print('Total Profit Apple:', int(sum(seller_apple.my_profit()))) print('Total Profit Samsung:', int(sum(seller_samsung.my_profit()))) print('Total Profit Xiaomi:', int(sum(seller_xiaomi.my_profit()))) print('Total Profit Huawei:', int(sum(seller_huawei.my_profit()))) print('\nPlotting graphs:\n') # record data in Google Spreadsheet (need install df2gspread) sellers_list = [seller_apple, seller_samsung, seller_xiaomi, seller_huawei] sheet_api.update_sheet(sellers_list) # Kill consumer threads for consumer in sensitive_customers: consumer.kill() for consumer in insensitive_customers: consumer.kill()
try: time.sleep(10) except KeyboardInterrupt: pass # kill seller thread seller_apple.kill() seller_samsung.kill() seller_sony.kill() # Plot the sales and expenditure trends plot(seller_apple) plot(seller_samsung) plot(seller_sony) print('Total Profit Apple:', seller_apple.my_profit()) print('Total Profit Samsung:', seller_samsung.my_profit()) print('Total Profit Sony:', seller_sony.my_profit()) # Kill consumer threads for consumer in customers: consumer.kill() print("[main] start updating google sheet.") from gsheet import update_google_sheet_csv update_google_sheet_csv(seller_apple) update_google_sheet_csv(seller_samsung) update_google_sheet_csv(seller_sony) print("Done")