-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing a duplicate firmware fetching class and makeing logging real
- Loading branch information
james townley
committed
Feb 24, 2016
1 parent
bbc7cf4
commit a124606
Showing
2 changed files
with
38 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
import os | ||
import sys | ||
import logging | ||
|
||
from firmware import MacFirmwareUpdater, LinuxFirmwareUpdater, WindowsFirmwareUpdater | ||
|
||
|
||
def get_firmware_updater(logger=None, bootloader_idvendor=0x0483, bootloader_idproduct=0xdf11, peachy_idvendor=0x16d0, peachy_idproduct=0x0af3): | ||
path = os.path.dirname(os.path.abspath(__file__)) | ||
logger = logging.getLogger('peachy') | ||
|
||
def get_firmware_updater(bootloader_idvendor=0x0483, bootloader_idproduct=0xdf11, peachy_idvendor=0x16d0, peachy_idproduct=0x0af3): | ||
logger.info("Firmware Flash Is Frozen: {}".format(str(getattr(sys, 'frozen', False)))) | ||
if 'darwin' in sys.platform: | ||
dependancies_path = os.path.join(path, 'dependancies', 'mac') | ||
return MacFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct, logger) | ||
if getattr(sys, 'frozen', False): | ||
dependancies_path = sys._MEIPASS | ||
else: | ||
dependancies_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dependancies', 'mac') | ||
if logger: | ||
logger.info("Firmware Flash Dependancies Path: {}".format(dependancies_path)) | ||
return MacFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct) | ||
elif 'win' in sys.platform: | ||
dependancies_path = os.path.join(path, 'dependancies', 'windows') | ||
return WindowsFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct, logger) | ||
if getattr(sys, 'frozen', False): | ||
dependancies_path = sys._MEIPASS | ||
else: | ||
dependancies_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dependancies', 'windows') | ||
return WindowsFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct) | ||
elif 'linux' in sys.platform: | ||
dependancies_path = os.path.join(path, 'dependancies', 'linux') | ||
return LinuxFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct, logger) | ||
if getattr(sys, 'frozen', False): | ||
dependancies_path = sys._MEIPASS | ||
else: | ||
dependancies_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dependancies', 'linux') | ||
return LinuxFirmwareUpdater(dependancies_path, bootloader_idvendor, bootloader_idproduct, peachy_idvendor, peachy_idproduct) | ||
else: | ||
if logger: | ||
logger.error("Platform {} is unsupported for firmware updates".format(sys.platform)) | ||
raise Exception("Unsupported Platform") | ||
logger.error("Platform {} is unsupported for firmware updates".format(sys.platform)) | ||
raise Exception("Unsupported Platform") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters