Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative code #561

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion edl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class main(metaclass=LogBase):
self.cdc.timeout = 1500
conninfo = self.doconnect(loop)
mode = conninfo["mode"]
if conninfo.get("data"):
if not conninfo.get("data"):
version = 2
else:
version = conninfo.get("data").version
Expand Down
4 changes: 2 additions & 2 deletions edlclient/Library/asmtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,5 @@ def main():
print(disasm(bytes(segment),len(segment)))
'''


main()
if __name__ == '__main__':
main()
6 changes: 3 additions & 3 deletions edlclient/Library/firehose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,9 +1333,9 @@ def patch_helper(gpt_data_a, gpt_data_b, guid_gpt_a, guid_gpt_b, partition_a, pa
rf_b = BytesIO(gpt_data_b)

entryoffset_a = partition_a.entryoffset - (
(guid_gpt_a.header.part_entry_start_lba - 2) * guid_gpt_a.sectorsize)
(guid_gpt_a.header.part_entry_start_lba - 2) * guid_gpt_a.sectorsize)
entryoffset_b = partition_b.entryoffset - (
(guid_gpt_b.header.part_entry_start_lba - 2) * guid_gpt_b.sectorsize)
(guid_gpt_b.header.part_entry_start_lba - 2) * guid_gpt_b.sectorsize)
rf_a.seek(entryoffset_a)
rf_b.seek(entryoffset_b)

Expand Down Expand Up @@ -1464,7 +1464,7 @@ def ensure_gpt_hdr_consistency(guid_gpt, backup_guid_gpt, gpt_data, backup_gpt_d
partition_a = backup_guid_gpt_a.partentries[partitionname_a]
if slot == "_a":
active_a = ((partition_a.flags >> (
AB_FLAG_OFFSET * 8)) & 0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE
AB_FLAG_OFFSET * 8)) & 0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE
if (active_a and slot_a_status) or (not active_a and slot_b_status):
return True

Expand Down
2 changes: 1 addition & 1 deletion edlclient/Library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def find_binary(self, data, strf, pos=0):
return None


def read_object(data: object, definition: object) -> dict:
def read_object(data: object, definition: list) -> dict:
"""
Unpacks a structure using the given data and definition.
"""
Expand Down
8 changes: 5 additions & 3 deletions edlclient/Tools/boottodwnload
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ class connection(metaclass=LogBase):
r = requests.get(url, headers=headers)
if b"FACTORY:ok" in r.content or b"success" in r.content:
print(
f"Detected a ZTE in web mode .... switching mode success (convert back by sending \"AT+ZCDRUN=F\" via AT port)")
f'Detected a ZTE in web mode .... switching mode success (convert back by sending "AT+ZCDRUN=F" via AT port)')
return self.waitforusb(vendor.zte.value, 0x0016)
return False

def getserialports(self):
@staticmethod
def getserialports():
return [port for port in serial.tools.list_ports.comports()]

def detectusbdevices(self):
@staticmethod
def detectusbdevices():
dev = usb.core.find(find_all=True)
ids = [deviceclass(cfg.idVendor, cfg.idProduct) for cfg in dev]
return ids
Expand Down
5 changes: 3 additions & 2 deletions edlclient/Tools/enableadb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# !!!!! If you use this code in commercial products, your product is automatically
# GPLv3 and has to be open sourced under GPLv3 as well. !!!!!
import argparse
import copy
import hashlib
import time

Expand Down Expand Up @@ -464,9 +465,9 @@ class adbtools(metaclass=LogBase):
# AUDIO - 0x00010000,
# ECM - 0x00080000,
# UBIST - 0x00200000
#if enable:
# if enable:
cmd = f"AT!USBCOMP={index},{type},%08X" % 0x0080010E
#else:
# else:
# cmd = f"AT!USBCOMP={index},{type},%08X" % 0x0000010D
resp = cn.send(cmd)
if resp != -1:
Expand Down
2 changes: 1 addition & 1 deletion edlclient/Tools/fhloaderparse
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def main(argv):
if not os.path.exists(os.path.join(outputdir, "Duplicate")):
os.mkdir(os.path.join(outputdir, "Duplicate"))

# Lets hash all the input files and extract the signature
# Let's hash all the input files and extract the signature
filelist = []
rt = open(os.path.join(outputdir, argv[1] + ".log"), "w")
for filename in file_list:
Expand Down
13 changes: 6 additions & 7 deletions edlclient/Tools/sierrakeygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# !!!!! If you use this code in commercial products, your product is automatically
# GPLv3 and has to be open sourced under GPLv3 as well. !!!!!
import copy
import sys
import argparse
import time
import serial.tools.list_ports
Expand Down Expand Up @@ -227,7 +226,7 @@ def run(self, devicegeneration, challenge, _type):
challenge = bytearray(unhexlify(challenge))

self.devicegeneration = devicegeneration
if not devicegeneration in prodtable:
if devicegeneration not in prodtable:
print("Sorry, " + devicegeneration + " not supported.")
exit(0)

Expand Down Expand Up @@ -577,9 +576,9 @@ def openlock(self):
return False


def main(args):
def main():
version = "1.5"
info = 'Sierra Wireless Generator ' + version + ' (c) B. Kerler 2019-2021'
info = f'Sierra Wireless Generator {version} (c) B. Kerler 2019-2024'
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=info)

parser.add_argument(
Expand Down Expand Up @@ -674,14 +673,14 @@ def main(args):
kg = SierraKeygen(None, devicegeneration)
if openlock != "":
resp = kg.keygen.run(devicegeneration, openlock, 0)
print("AT!OPENLOCK=\"" + resp + "\"")
print(f'AT!OPENLOCK="{resp}"')
elif openmep != "":
resp = kg.keygen.run(devicegeneration, openmep, 1)
print("AT!OPENMEP=\"" + resp + "\"")
print(f'AT!OPENMEP="{resp}"')
elif opencnd != "":
resp = kg.keygen.run(devicegeneration, opencnd, 2)
print("AT!OPENCND=\"" + resp + "\"")


if __name__ == '__main__':
main(sys.argv)
main()
30 changes: 15 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
from setuptools import setup, find_packages
import os

setup(
name='edlclient',
version='3.62',
packages=find_packages(),
long_description=open("README.md").read(),
scripts=['edl','edlclient/Tools/qc_diag.py','edlclient/Tools/sierrakeygen.py','edlclient/Tools/boottodwnload','edlclient/Tools/enableadb','edlclient/Tools/fhloaderparse','edlclient/Tools/beagle_to_loader'],
data_files = ['LICENSE','README.md'],
scripts=['edl', 'edlclient/Tools/qc_diag.py', 'edlclient/Tools/sierrakeygen.py', 'edlclient/Tools/boottodwnload',
'edlclient/Tools/enableadb', 'edlclient/Tools/fhloaderparse', 'edlclient/Tools/beagle_to_loader'],
data_files=['LICENSE', 'README.md'],
long_description_content_type="text/markdown",
url='https://github.com/bkerler/edl',
project_urls={
Expand All @@ -21,18 +21,18 @@
],
license='GPLv3 License',
install_requires=[
'colorama',
'docopt',
'usb',
'pyusb',
'pyserial',
'lxml',
'pylzma',
'pycryptodome',
'wheel',
'Exscript',
'requests',
'passlib'
'colorama',
'docopt',
'usb',
'pyusb',
'pyserial',
'lxml',
'pylzma',
'pycryptodome',
'wheel',
'Exscript',
'requests',
'passlib'
],
author='B. Kerler',
author_email='info@revskills.de',
Expand Down
Loading