From 7b0536dcd70b53fc7b09903dde60a1f566ca73a6 Mon Sep 17 00:00:00 2001 From: David Parsons Date: Sat, 4 Jun 2016 19:51:17 +0100 Subject: [PATCH] Fixed error with MLB generatio & changed pyinstaller folders --- .gitignore | 7 +--- dumpsmc/dumpsmc.spec | 17 --------- generate.py | 79 +++++++++++++++++++++++++++++++----------- gettools/gettools.spec | 17 --------- unlocker/unlocker.spec | 17 --------- 5 files changed, 60 insertions(+), 77 deletions(-) delete mode 100644 dumpsmc/dumpsmc.spec delete mode 100644 gettools/gettools.spec delete mode 100644 unlocker/unlocker.spec diff --git a/.gitignore b/.gitignore index b500c1d..14646f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ backup/ tools/ .idea/ -unlocker/build -unlocker/dist -dumpsmc/build -dumpsmc/dist -gettools/build -gettools/dist \ No newline at end of file +pyinstaller/ diff --git a/dumpsmc/dumpsmc.spec b/dumpsmc/dumpsmc.spec deleted file mode 100644 index 8c07e74..0000000 --- a/dumpsmc/dumpsmc.spec +++ /dev/null @@ -1,17 +0,0 @@ -# -*- mode: python -*- -a = Analysis(['D:\\vmware\\unlocker\\dumpsmc.py'], - pathex=['D:\\PyInstaller-2.1\\dumpsmc'], - hiddenimports=[], - hookspath=None, - runtime_hooks=None) -pyz = PYZ(a.pure) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='dumpsmc.exe', - debug=False, - strip=None, - upx=True, - console=True ) diff --git a/generate.py b/generate.py index 55a3e3b..74f40ee 100644 --- a/generate.py +++ b/generate.py @@ -1,19 +1,48 @@ +""" +The MIT License (MIT) + +Copyright (c) 2016 Dave Parsons + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import json import random import string +import sys # Years and months # 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 -years = ['C','D','F','G','H','J','K','L','M','N','P','Q','R','T','V','W','X','Y','1','2','3','4','5','6','7','8'] +years = ['C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '1', '2', '3', '4', + '5', '6', '7', '8'] # Week numbers from 1-52 # B is used to shift indexing to 1 and is not used -weeks = ['B','C','D','F','G','H','J','K','L','M','N','P','Q','R','T','V','W','X','Y','1','2','3','4','5','6','7','8', - 'C','D','F','G','H','J','K','L','M','N','P','Q','R','T','V','W','X','Y','1','2','3','4','5','6','7','8'] +weeks = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '1', '2', '3', + '4', '5', '6', '7', '8', + 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '1', '2', '3', '4', + '5', '6', '7', '8'] # Values to generate 3 code production number -production = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - '0','1','2','3','4','5','6','7','8','9'] +production = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', + 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] # MLB codes ttt = ['200', '600', '403', '404', '405', '303', '108', '207', '609', '501', '306', '102', '701', '301', '501', @@ -26,14 +55,14 @@ eeee = ['DYWF', 'F117', 'F502', 'F505', 'F9GY', 'F9H0', 'F9H1', 'F9H2', 'DYWD', 'FF4L', 'FF4M', 'FF4N', 'FF4P', 'DNY3', 'DP00', 'DJWK', 'DM66', 'DNJK', 'DKG1', 'DM65', 'DNJJ', 'DKG2', 'DM67', 'DNJL', 'DJWM', 'DMT3', 'DMT5', 'DJWN', 'DM69', 'DJWP', 'DM6C'] -kk = ['1H', '1M' 'AD' '1F' 'A8' 'UE' 'JA' 'JC' '8C' 'CB' 'FB'] +kk = ['1H', '1M', 'AD', '1F', 'A8', 'UE', 'JA', 'JC', '8C', 'CB', 'FB'] # Loaded JSON model database smbiosdb = {} model = None -year = None -week = None +year = 2010 +week = 1 yearweek = None run = None mlb = None @@ -51,10 +80,10 @@ def getmlb(): global mlb if model['serial.type'] == 11: - mlb = yearweek + '0'+ run + id_generator(4) + mlb = yearweek + '0' + run + id_generator(4) elif model['serial.type'] == 12: - mlb = 'C02{0}{1}{2}{3}{4}{5}'.format(str(year - 2010), str(week).zfill(2), - random.choice(ttt), random.choice(cc), random.choice(eeee), random.choice(kk)) + mlb = 'C02{0}{1}{2}{3}{4}{5}'.format(str(year - 2010), str(week).zfill(2), random.choice(ttt), + random.choice(cc), random.choice(eeee), random.choice(kk)) else: pass @@ -69,14 +98,17 @@ def getmodel(): while True: try: index = int(raw_input('Please enter model family [1-6]: ')) - except: + except KeyboardInterrupt: + print "Goodbye!" + sys.exit(0) + except ValueError: print "This is not a number." else: if (index >= 1) and (index <= 6): modeltype = modeltypes[index - 1] break else: - print 'Invalid model family selected: ', index + print 'Invalid model family selected: ', index # Now build a menu with selected models i = 1 @@ -90,10 +122,13 @@ def getmodel(): while True: try: index = int(raw_input('Please enter model [1-{}]: '.format(i - 1))) - except: + except KeyboardInterrupt: + print "Goodbye!" + sys.exit(0) + except ValueError: print "This is not a number." else: - if (index >= 1) and (index <= (i-1)): + if (index >= 1) and (index <= (i - 1)): model = models[index - 1] break else: @@ -136,14 +171,17 @@ def getweek(): # Get a week number while True: try: - week = int(input('Please enter week for year {0} (1 - 53): '.format(year))) - except: + week = int(input('Please enter week for year {0} (1 - 52): '.format(year))) + except KeyboardInterrupt: + print "Goodbye!" + sys.exit(0) + except ValueError: print "This is not a week number." else: - if (week >= 1) and (week <= 53): + if (week >= 1) and (week <= 52): break else: - print 'Invalid week: ', week + print 'Invalid week: ', week # Format date based on serial number length if serlen == 11: @@ -169,6 +207,7 @@ def main(): getweek() getrun() getmlb() + getrom() print print '# Passthru host definitions - FALSE' print 'board-id.reflectHost = "FALSE"' @@ -190,4 +229,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/gettools/gettools.spec b/gettools/gettools.spec deleted file mode 100644 index cb35952..0000000 --- a/gettools/gettools.spec +++ /dev/null @@ -1,17 +0,0 @@ -# -*- mode: python -*- -a = Analysis(['D:\\vmware\\unlocker\\gettools.py'], - pathex=['D:\\PyInstaller-2.1\\gettools'], - hiddenimports=[], - hookspath=None, - runtime_hooks=None) -pyz = PYZ(a.pure) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='gettools.exe', - debug=False, - strip=None, - upx=True, - console=True ) diff --git a/unlocker/unlocker.spec b/unlocker/unlocker.spec deleted file mode 100644 index 9889cf8..0000000 --- a/unlocker/unlocker.spec +++ /dev/null @@ -1,17 +0,0 @@ -# -*- mode: python -*- -a = Analysis(['D:\\vmware\\unlocker\\unlocker.py'], - pathex=['D:\\PyInstaller-2.1\\unlocker'], - hiddenimports=[], - hookspath=None, - runtime_hooks=None) -pyz = PYZ(a.pure) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='unlocker.exe', - debug=False, - strip=None, - upx=True, - console=True )