Completed
Branch master (470cbf)
by John
01:11
created

tcl_download()   B

Complexity

Conditions 2

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 28
rs 8.8571
ccs 12
cts 12
cp 1
crap 2
1
#!/usr/bin/env python3
2 3
"""This module contains various utilities for the scripts folder."""
3
4 5
import os  # path work
5 5
import getpass  # invisible password
6 5
import argparse  # generic parser
7 5
import hashlib  # hashes
8 5
import sys  # getattr
9 5
import shutil  # folder removal
10 5
import subprocess  # running cfp/cap
11 5
import glob  # file lookup
12 5
import threading  # run stuff in background
13 5
import requests  # session
14 5
from bbarchivist import utilities  # little things
15 5
from bbarchivist import decorators  # decorating functions
16 5
from bbarchivist import barutils  # file system work
17 5
from bbarchivist import archiveutils  # archive support
18 5
from bbarchivist import bbconstants  # constants
19 5
from bbarchivist import gpgutils  # gpg
20 5
from bbarchivist import hashutils  # file hashes
21 5
from bbarchivist import networkutils  # network tools
22 5
from bbarchivist import textgenerator  # writing text to file
23 5
from bbarchivist import smtputils  # email
24 5
from bbarchivist import sqlutils  # sql
25
26 5
__author__ = "Thurask"
27 5
__license__ = "WTFPL v2"
28 5
__copyright__ = "2015-2017 Thurask"
29
30
31 5
def shortversion():
32
    """
33
    Get short app version (Git tag).
34
    """
35 5
    if not getattr(sys, 'frozen', False):
36 5
        ver = bbconstants.VERSION
37
    else:
38 5
        verfile = glob.glob(os.path.join(os.getcwd(), "version.txt"))[0]
39 5
        with open(verfile) as afile:
40 5
            ver = afile.read()
41 5
    return ver
42
43
44 5
def longversion():
45
    """
46
    Get long app version (Git tag + commits + hash).
47
    """
48 5
    if not getattr(sys, 'frozen', False):
49 5
        ver = (bbconstants.LONGVERSION, bbconstants.COMMITDATE)
50
    else:
51 5
        verfile = glob.glob(os.path.join(os.getcwd(), "longversion.txt"))[0]
52 5
        with open(verfile) as afile:
53 5
            ver = afile.read().split("\n")
54 5
    return ver
55
56
57 5
def default_parser(name=None, desc=None, flags=None, vers=None):
58
    """
59
    A generic form of argparse's ArgumentParser.
60
61
    :param name: App name.
62
    :type name: str
63
64
    :param desc: App description.
65
    :type desc: str
66
67
    :param flags: Tuple of sections to add.
68
    :type flags: tuple(str)
69
70
    :param vers: Versions: [git commit hash, git commit date]
71
    :param vers: list(str)
72
    """
73 5
    if vers is None:
74 5
        vers = longversion()
75 5
    parser = argparse.ArgumentParser(
76
        prog=name,
77
        description=desc,
78
        epilog="https://github.com/thurask/bbarchivist")
79 5
    parser.add_argument(
80
        "-v",
81
        "--version",
82
        action="version",
83
        version="{0} {1} committed {2}".format(parser.prog, vers[0], vers[1]))
84 5
    if flags is not None:
85 5
        if "folder" in flags:
86 5
            parser.add_argument(
87
                "-f",
88
                "--folder",
89
                dest="folder",
90
                help="Working folder",
91
                default=None,
92
                metavar="DIR",
93
                type=utilities.file_exists)
94 5
        if "osr" in flags:
95 5
            parser.add_argument(
96
                "os",
97
                help="OS version")
98 5
            parser.add_argument(
99
                "radio",
100
                help="Radio version, 10.x.y.zzzz",
101
                nargs="?",
102
                default=None)
103 5
            parser.add_argument(
104
                "swrelease",
105
                help="Software version, 10.x.y.zzzz",
106
                nargs="?",
107
                default=None)
108 5
    return parser
109
110
111 5
def generic_windows_shim(scriptname, scriptdesc, target, version):
112
    """
113
    Generic CFP/CAP runner; Windows only.
114
115
    :param scriptname: Script name, 'bb-something'.
116
    :type scriptname: str
117
118
    :param scriptdesc: Script description, i.e. scriptname -h.
119
    :type scriptdesc: str
120
121
    :param target: Path to file to execute.
122
    :type target: str
123
124
    :param version: Version of target.
125
    :type version: str
126
    """
127 5
    parser = default_parser(scriptname, scriptdesc)
128 5
    capver = "|{0}".format(version)
129 5
    parser = external_version(parser, capver)
130 5
    parser.parse_known_args(sys.argv[1:])
131 5
    if utilities.is_windows():
132 5
        subprocess.call([target] + sys.argv[1:])
133
    else:
134 5
        print("Sorry, Windows only.")
135
136
137 5
def external_version(parser, addition):
138
    """
139
    Modify the version string of argparse.ArgumentParser, adding something.
140
141
    :param parser: Parser to modify.
142
    :type parser: argparse.ArgumentParser
143
144
    :param addition: What to add.
145
    :type addition: str
146
    """
147 5
    verarg = [arg for arg in parser._actions if isinstance(arg, argparse._VersionAction)][0]
148 5
    verarg.version = "{1}{0}".format(addition, verarg.version)
149 5
    return parser
150
151
152 5
def return_radio_version(osversion, radioversion=None):
153
    """
154
    Increment radio version, if need be.
155
156
    :param osversion: OS version.
157
    :type osversion: str
158
159
    :param radioversion: Radio version, None if incremented.
160
    :type radioversion: str
161
    """
162 5
    if radioversion is None:
163 5
        radioversion = utilities.increment(osversion, 1)
164 5
    return radioversion
165
166
167 5
def sw_check_contingency(softwareversion):
168
    """
169
    Ask in the event software release isn't found.
170
171
    :param softwareversion: Software release version.
172
    :type softwareversion: str
173
    """
174 5
    if softwareversion == "SR not in system":
175 5
        print("SOFTWARE RELEASE NOT FOUND")
176 5
        cont = utilities.s2b(input("INPUT MANUALLY? Y/N: "))
177 5
        if cont:
178 5
            softwareversion = input("SOFTWARE RELEASE: ")
179 5
            swchecked = False
180
        else:
181 5
            print("\nEXITING...")
182 5
            raise SystemExit  # bye bye
183
    else:
184 5
        swchecked = True
185 5
    return softwareversion, swchecked
186
187
188 5
def return_sw_checked(softwareversion, osversion):
189
    """
190
    Check software existence, return boolean.
191
192
    :param softwareversion: Software release version.
193
    :type softwareversion: str
194
195
    :param osversion: OS version.
196
    :type osversion: str
197
    """
198 5
    if softwareversion is None:
199 5
        serv = bbconstants.SERVERS["p"]
200 5
        softwareversion = networkutils.sr_lookup(osversion, serv)
201 5
        softwareversion, swchecked = sw_check_contingency(softwareversion)
202
    else:
203 5
        swchecked = True
204 5
    return softwareversion, swchecked
205
206
207 5
def return_radio_sw_checked(altsw, radioversion):
208
    """
209
    Check radio software existence, return boolean.
210
211
    :param altsw: Software release version.
212
    :type altsw: str
213
214
    :param radioversion: Radio version.
215
    :type radioversion: str
216
    """
217 5
    if altsw == "checkme":
218 5
        serv = bbconstants.SERVERS["p"]
219 5
        testos = utilities.increment(radioversion, -1)
220 5
        altsw = networkutils.sr_lookup(testos, serv)
221 5
        altsw, altchecked = sw_check_contingency(altsw)
222
    else:
223 5
        altchecked = True
224 5
    return altsw, altchecked
225
226
227 5
def check_sw(baseurl, softwareversion, swchecked, altsw=False):
228
    """
229
    Check existence of software release.
230
231
    :param baseurl: Base URL (from http to hashed SW release).
232
    :type basurl: str
233
234
    :param softwareversion: Software release.
235
    :type softwareversion: str
236
237
    :param swchecked: If we checked the sw release already.
238
    :type swchecked: bool
239
240
    :param altsw: If this is the radio-only release. Default is false.
241
    :type altsw: bool
242
    """
243 5
    message = "CHECKING RADIO SOFTWARE RELEASE..." if altsw else "CHECKING SOFTWARE RELEASE..."
244 5
    print(message)
245 5
    if not swchecked:
246 5
        avlty = networkutils.availability(baseurl)
247 5
        if avlty:
248 5
            print("SOFTWARE RELEASE {0} EXISTS".format(softwareversion))
249
        else:
250 5
            print("SOFTWARE RELEASE {0} NOT FOUND".format(softwareversion))
251 5
            cont = utilities.s2b(input("CONTINUE? Y/N: "))
252 5
            if not cont:
253 5
                print("\nEXITING...")
254 5
                raise SystemExit
255
    else:
256 5
        print("SOFTWARE RELEASE {0} EXISTS".format(softwareversion))
257
258
259 5
def check_radio_sw(alturl, altsw, altchecked):
260
    """
261
    Check existence of radio software release.
262
263
    :param alturl: Radio base URL (from http to hashed SW release).
264
    :type alturl: str
265
266
    :param altsw: Radio software release.
267
    :type altsw: str
268
269
    :param altchecked: If we checked the sw release already.
270
    :type altchecked: bool
271
    """
272 5
    return check_sw(alturl, altsw, altchecked, True)
273
274
275 5
def check_altsw(altcheck=False):
276
    """
277
    Ask for and return alternate software release, if needed.
278
279
    :param altcheck: If we're using an alternate software release.
280
    :type altcheck: bool
281
    """
282 5
    if altcheck:
283 5
        altsw = input("RADIO SOFTWARE RELEASE (PRESS ENTER TO GUESS): ")
284 5
        if not altsw:
285 5
            altsw = "checkme"
286
    else:
287 5
        altsw = None
288 5
    return altsw
289
290
291 5
def check_os_single(osurl, osversion, device):
292
    """
293
    Check existence of single OS link.
294
295
    :param radiourl: Radio URL to check.
296
    :type radiourl: str
297
298
    :param radioversion: Radio version.
299
    :type radioversion: str
300
301
    :param device: Device family.
302
    :type device: int
303
    """
304 5
    osav = networkutils.availability(osurl)
305 5
    if not osav:
306 5
        print("{0} NOT AVAILABLE FOR {1}".format(osversion, bbconstants.DEVICES[device]))
307 5
        cont = utilities.s2b(input("CONTINUE? Y/N: "))
308 5
        if not cont:
309 5
            print("\nEXITING...")
310 5
            raise SystemExit
311
312
313 5
def check_os_bulk(osurls):
314
    """
315
    Check existence of list of OS links.
316
317
    :param osurls: OS URLs to check.
318
    :type osurls: list(str)
319
    """
320 5
    sess = requests.Session()
321 5
    for url in osurls:
322 5
        osav = networkutils.availability(url, sess)
323 5
        if osav:
324 5
            break
325
    else:
326 5
        print("OS VERSION NOT FOUND")
327 5
        cont = utilities.s2b(input("CONTINUE? Y/N: "))
328 5
        if not cont:
329 5
            print("\nEXITING...")
330 5
            raise SystemExit
331
332
333 5
def check_radio_single(radiourl, radioversion):
334
    """
335
    Check existence of single radio link.
336
337
    :param radiourl: Radio URL to check.
338
    :type radiourl: str
339
340
    :param radioversion: Radio version.
341
    :type radioversion: str
342
    """
343 5
    radav = networkutils.availability(radiourl)
344 5
    if not radav:
345 5
        print("RADIO VERSION NOT FOUND")
346 5
        cont = utilities.s2b(input("INPUT MANUALLY? Y/N: "))
347 5
        if cont:
348 5
            rad2 = input("RADIO VERSION: ")
349 5
            radiourl = radiourl.replace(radioversion, rad2)
350 5
            radioversion = rad2
351
        else:
352 5
            going = utilities.s2b(input("KEEP GOING? Y/N: "))
353 5
            if not going:
354 5
                print("\nEXITING...")
355 5
                raise SystemExit
356 5
    return radiourl, radioversion
357
358
359 5
def check_radio_bulk(radiourls, radioversion):
360
    """
361
    Check existence of list of radio links.
362
363
    :param radiourls: Radio URLs to check.
364
    :type radiourls: list(str)
365
366
    :param radioversion: Radio version.
367
    :type radioversion: str
368
    """
369 5
    sess = requests.Session()
370 5
    for url in radiourls:
371 5
        radav = networkutils.availability(url, sess)
372 5
        if radav:
373 5
            break
374
    else:
375 5
        radiourls, radioversion = check_radio_bulk_notfound(radiourls, radioversion)
376 5
    return radiourls, radioversion
377
378
379 5
def check_radio_bulk_notfound(radiourls, radioversion):
380
    """
381
    What to do if radio links aren't found.
382
383
    :param radiourls: Radio URLs to check.
384
    :type radiourls: list(str)
385
386
    :param radioversion: Radio version.
387
    :type radioversion: str
388
    """
389 5
    print("RADIO VERSION NOT FOUND")
390 5
    cont = utilities.s2b(input("INPUT MANUALLY? Y/N: "))
391 5
    if cont:
392 5
        radiourls, radioversion = check_radio_bulk_go(radiourls, radioversion)
393
    else:
394 5
        check_radio_bulk_stop()
395 5
    return radiourls, radioversion
396
397
398 5
def check_radio_bulk_go(radiourls, radioversion):
399
    """
400
    Replace radio version and URLs, and keep going.
401
402
    :param radiourls: Radio URLs to check.
403
    :type radiourls: list(str)
404
405
    :param radioversion: Radio version.
406
    :type radioversion: str
407
    """
408 5
    rad2 = input("RADIO VERSION: ")
409 5
    radiourls = [url.replace(radioversion, rad2) for url in radiourls]
410 5
    radioversion = rad2
411 5
    return radiourls, radioversion
412
413
414 5
def check_radio_bulk_stop():
415
    """
416
    Ask if we should keep going once no radio has been found.
417
    """
418 5
    going = utilities.s2b(input("KEEP GOING? Y/N: "))
419 5
    if not going:
420 5
        print("\nEXITING...")
421 5
        raise SystemExit
422
423
424 5
def bulk_avail(urllist):
425
    """
426
    Filter 404 links out of URL list.
427
428
    :param urllist: URLs to check.
429
    :type urllist: list(str)
430
    """
431 5
    sess = requests.Session()
432 5
    url2 = [x for x in urllist if networkutils.availability(x, sess)]
433 5
    return url2
434
435
436 5
def get_baseurls(softwareversion, altsw=None):
437
    """
438
    Generate base URLs for bar links.
439
440
    :param softwareversion: Software version.
441
    :type softwareversion: str
442
443
    :param altsw: Radio software version, if necessary.
444
    :type altsw: str
445
    """
446 5
    baseurl = utilities.create_base_url(softwareversion)
447 5
    alturl = utilities.create_base_url(altsw) if altsw else None
448 5
    return baseurl, alturl
449
450
451 5
def get_sz_executable(compmethod):
452
    """
453
    Get 7z executable.
454
455
    :param compmethod: Compression method.
456
    :type compmethod: str
457
    """
458 5
    if compmethod != "7z":
459 5
        szexe = ""
460
    else:
461 5
        print("CHECKING PRESENCE OF 7ZIP...")
462 5
        psz = utilities.prep_seven_zip(True)
463 5
        if psz:
464 5
            print("7ZIP OK")
465 5
            szexe = utilities.get_seven_zip(False)
466
        else:
467 5
            szexe = ""
468 5
            print("7ZIP NOT FOUND")
469 5
            cont = utilities.s2b(input("CONTINUE? Y/N "))
470 5
            if cont:
471 5
                print("FALLING BACK TO ZIP...")
472 5
                compmethod = "zip"
473
            else:
474 5
                print("\nEXITING...")
475 5
                raise SystemExit  # bye bye
476 5
    return compmethod, szexe
477
478
479 5
def test_bar_files(localdir, urllist):
480
    """
481
    Test bar files after download.
482
483
    :param localdir: Directory.
484
    :type localdir: str
485
486
    :param urllist: List of URLs to check.
487
    :type urllist: list(str)
488
    """
489 5
    brokenlist = []
490 5
    print("TESTING BAR FILES...")
491 5
    for file in os.listdir(localdir):
492 5
        brokenlist = test_bar_files_individual(file, localdir, urllist, brokenlist)
493 5
    if brokenlist:
494 5
        print("SOME FILES ARE BROKEN!")
495 5
        utilities.lprint(brokenlist)
496 5
        raise SystemExit
497
    else:
498 5
        print("BAR FILES DOWNLOADED OK")
499
500
501 5
def test_bar_files_individual(file, localdir, urllist, brokenlist):
502
    """
503
    Test bar file after download.
504
505
    :param file: Bar file to check.
506
    :type file: str
507
508
    :param localdir: Directory.
509
    :type localdir: str
510
511
    :param urllist: List of URLs to check.
512
    :type urllist: list(str)
513
514
    :param brokenlist: List of URLs to download later.
515
    :type brokenlist: list(str)
516
    """
517 5
    if file.endswith(".bar"):
518 5
        print("TESTING: {0}".format(file))
519 5
        thepath = os.path.abspath(os.path.join(localdir, file))
520 5
        brokens = barutils.bar_tester(thepath)
521 5
        if brokens is not None:
522 5
            os.remove(brokens)
523 5
            for url in urllist:
524 5
                if brokens in url:
525 5
                    brokenlist.append(url)
526 5
    return brokenlist
527
528
529 5
def test_signed_files(localdir):
530
    """
531
    Test signed files after extract.
532
533
    :param localdir: Directory.
534
    :type localdir: str
535
    """
536 5
    print("TESTING SIGNED FILES...")
537 5
    for file in os.listdir(localdir):
538 5
        if file.endswith(".bar"):
539 5
            print("TESTING: {0}".format(file))
540 5
            signname, signhash = barutils.retrieve_sha512(os.path.join(localdir, file))
541 5
            sha512ver = barutils.verify_sha512(os.path.join(localdir, signname.decode("utf-8")), signhash)
542 5
            if not sha512ver:
543 5
                print("{0} IS BROKEN".format((file)))
544 5
                break
545
    else:
546 5
        print("ALL FILES EXTRACTED OK")
547
548
549 5
def test_loader_files(localdir):
550
    """
551
    Test loader files after creation.
552
553
    :param localdir: Directory.
554
    :type localdir: str
555
    """
556 5
    if not utilities.is_windows():
557 5
        pass
558
    else:
559 5
        print("TESTING LOADER FILES...")
560 5
        brokens = utilities.verify_bulk_loaders(localdir)
561 5
        if brokens:
562 5
            print("BROKEN FILES:")
563 5
            utilities.lprint(brokens)
564 5
            raise SystemExit
565
        else:
566 5
            print("ALL FILES CREATED OK")
567
568
569 5
def test_single_loader(loaderfile):
570
    """
571
    Test single loader file after creation.
572
573
    :param loaderfile: File to check.
574
    :type loaderfile: str
575
    """
576 5
    if not utilities.is_windows():
577 5
        pass
578
    else:
579 5
        print("TESTING LOADER...")
580 5
        if not utilities.verify_loader_integrity(loaderfile):
581 5
            print("{0} IS BROKEN!".format(os.path.basename(loaderfile)))
582 5
            raise SystemExit
583
        else:
584 5
            print("LOADER CREATED OK")
585
586
587 5
def prod_avail(results, mailer=False, osversion=None, password=None):
588
    """
589
    Clean availability for production lookups for autolookup script.
590
591
    :param results: Result dict.
592
    :type results: dict(str: str)
593
594
    :param mailer: If we're mailing links. Default is false.
595
    :type mailer: bool
596
597
    :param osversion: OS version.
598
    :type osversion: str
599
600
    :param password: Email password.
601
    :type password: str
602
    """
603 5
    prel = results['p']
604 5
    if prel != "SR not in system" and prel is not None:
605 5
        pav = "PD"
606 5
        baseurl = utilities.create_base_url(prel)
607 5
        avail = networkutils.availability(baseurl)
608 5
        is_avail = "Available" if avail else "Unavailable"
609 5
        prod_avail_mailprep(prel, avail, osversion, mailer, password)
610
    else:
611 5
        pav = "  "
612 5
        is_avail = "Unavailable"
613 5
    return prel, pav, is_avail
614
615
616 5
def prod_avail_mailprep(prel, avail, osversion=None, mailer=False, password=None):
617
    """
618
    Do SQL/SMTP prep work after a good production lookup hit.
619
620
    :param prel: Software lookup result.
621
    :type prel: str
622
623
    :param avail: If software lookup result is available for download.
624
    :type avail: bool
625
626
    :param osversion: OS version.
627
    :type osversion: str
628
629
    :param mailer: If we're mailing links. Default is false.
630
    :type mailer: bool
631
632
    :param password: Email password.
633
    :type password: str
634
    """
635 5
    if avail and mailer:
636 5
        sqlutils.prepare_sw_db()
637 5
        if not sqlutils.check_exists(osversion, prel):
638 5
            rad = utilities.increment(osversion, 1)
639 5
            linkgen(osversion, rad, prel, temp=True)
640 5
            smtputils.prep_email(osversion, prel, password)
641
642
643 5
def comp_joiner(rootdir, localdir, filelist):
644
    """
645
    Join rootdir, localdir to every file in filelist.
646
647
    :param rootdir: Root directory.
648
    :type rootdir: str
649
650
    :param localdir: Subfolder inside rootdir.
651
    :type localdir: str
652
653
    :param filelist: List of files to return this path for.
654
    :type filelist: list(str)
655
    """
656 5
    joinedfiles = [os.path.join(rootdir, localdir, os.path.basename(x)) for x in filelist]
657 5
    return joinedfiles
658
659
660 5
def kernchecker_prep(kernlist):
661
    """
662
    Prepare output from kernel list.
663
664
    :param kernlist: List of kernel branches.
665
    :type kernlist: list(str)
666
    """
667 5
    splitkerns = [x.split("/") for x in kernlist]
668 5
    platforms = list({x[0] for x in splitkerns})
669 5
    kerndict = kernchecker_dict(splitkerns, platforms)
670 5
    return kerndict
671
672
673 5
def kernchecker_dict(splitkerns, platforms):
674
    """
675
    Prepare results dictionary.
676
677
    :param splitkerns: Split kernel branches.
678
    :type splitkerns: list(str)
679
680
    :param platforms: List of platform dicts.
681
    :type platforms: list(dict)
682
    """
683 5
    kerndict = {x: [] for x in platforms}
684 5
    for kernel in splitkerns:
685 5
        kerndict[kernel[0]].append("\t{0}".format(kernel[1]))
686 5
    return kerndict
687
688
689 5
def tclloader_prep(loaderfile, directory=False):
690
    """
691
    Prepare directory name and OS version.
692
693
    :param loaderfile: Path to input file/folder.
694
    :type loaderfile: str
695
696
    :param directory: If the input file is a folder. Default is False.
697
    :type directory: bool
698
    """
699 5
    loaderdir = loaderfile if directory else loaderfile.replace(".zip", "")
700 5
    osver = loaderdir.split("-")[-1]
701 5
    return loaderdir, osver
702
703
704 5
def tclloader_filename(loaderdir, osver, loadername=None):
705
    """
706
    Prepare platform and filename.
707
708
    :param loaderdir: Path to input folder.
709
    :type loaderdir: str
710
711
    :param osver: OS version.
712
    :type osver: str
713
714
    :param loadername: Name of final autoloader. Default is auto-generated.
715
    :type loadername: str
716
    """
717 5
    platform = os.listdir(os.path.join(loaderdir, "target", "product"))[0]
718 5
    if loadername is None:
719 5
        loadername = "{0}_autoloader_user-all-{1}".format(platform, osver)
720 5
    return loadername, platform
721
722
723 5
def tcl_download(downloadurl, filename, filesize, filehash):
724
    """
725
    Download autoloader file, rename, and verify.
726
727
    :param downloadurl: Download URL.
728
    :type downloadurl: str
729
730
    :param filename: Name of autoloader file.
731
    :type filename: str
732
733
    :param filesize: Size of autoloader file.
734
    :type filesize: str
735
736
    :param filehash: SHA-1 hash of autoloader file.
737
    :type filehash: str
738
    """
739 5
    print("FILENAME: {0}".format(filename))
740 5
    print("LENGTH: {0}".format(utilities.fsizer(filesize)))
741 5
    networkutils.download(downloadurl)
742 5
    print("DOWNLOAD COMPLETE")
743 5
    os.rename(downloadurl.split("/")[-1], filename)
744 5
    method = hashutils.get_engine("sha1")
745 5
    shahash = hashutils.hashlib_hash(filename, method)
746 5
    if shahash == filehash:
747 5
        print("HASH CHECK OK")
748
    else:
749 5
        print(shahash)
750 5
        print("HASH FAILED!")
751
752
753 5
def tcl_prd_scan(curef, download=False, mode=4, fvver="AAM481"):
754
    """
755
    Scan one PRD and produce download URL and filename.
756
757
    :param curef: PRD of the phone variant to check.
758
    :type curef: str
759
760
    :param download: If we'll download the file that this returns. Default is False.
761
    :type download: bool
762
763
    :param mode: 4 if downloading autoloaders, 2 if downloading OTA deltas.
764
    :type mode: int
765
766
    :param fvver: Initial software version, must be specific if downloading OTA deltas.
767
    :type fvver: str
768
    """
769 5
    sess = requests.Session()
770 5
    ctext = networkutils.tcl_check(curef, sess, mode, fvver)
771 5
    if ctext is None:
772 5
        raise SystemExit
773 5
    tvver, firmwareid, filename, filesize, filehash = networkutils.parse_tcl_check(ctext)
774 5
    salt = networkutils.tcl_salt()
775 5
    vkhsh = networkutils.vkhash(curef, tvver, firmwareid, salt, mode, fvver)
776 5
    updatetext = networkutils.tcl_download_request(curef, tvver, firmwareid, salt, vkhsh, sess, mode, fvver)
777 5
    downloadurl = networkutils.parse_tcl_download_request(updatetext)
778 5
    statcode = networkutils.getcode(downloadurl, sess)
779 5
    print("{0}: HTTP {1}".format(filename, statcode))
780 5
    print(downloadurl)
781 5
    if statcode == 200 and download:
782 5
        tcl_download(downloadurl, filename, filesize, filehash)
783
784
785 5
def linkgen_sdk_dicter(indict, origtext, newtext):
786
    """
787
    Prepare SDK radio/OS dictionaries.
788
789
    :param indict: Dictionary of radio and OS pairs.
790
    :type: dict(str:str)
791
792
    :param origtext: String in indict's values that must be replaced.
793
    :type origtext: str
794
795
    :param newtext: What to replace origtext with.
796
    :type newtext: str
797
    """
798 5
    return {key: val.replace(origtext, newtext) for key, val in indict.items()}
799
800
801 5
def linkgen_sdk(sdk, oses, cores):
802
    """
803
    Generate SDK debrick/core images.
804
805
    :param sdk: If we specifically want SDK images. Default is False.
806
    :type sdk: bool
807
808
    :param oses: Dictionary of radio and debrick pairs.
809
    :type oses: dict(str:str)
810
811
    :param cores: Dictionary of radio and core pairs.
812
    :type cores: dict(str:str)
813
    """
814 5
    if sdk:
815 5
        oses2 = linkgen_sdk_dicter(oses, "factory_sfi", "sdk")
816 5
        cores2 = linkgen_sdk_dicter(cores, "factory_sfi", "sdk")
817 5
        oses = linkgen_sdk_dicter(oses2, "verizon_sfi", "sdk")
818 5
        cores = linkgen_sdk_dicter(cores2, "verizon_sfi", "sdk")
819 5
    return oses, cores
820
821
822 5
def linkgen(osversion, radioversion=None, softwareversion=None, altsw=None, temp=False, sdk=False):
823
    """
824
    Generate debrick/core/radio links for given OS, radio, software release.
825
826
    :param osversion: OS version, 10.x.y.zzzz.
827
    :type osversion: str
828
829
    :param radioversion: Radio version, 10.x.y.zzzz. Can be guessed.
830
    :type radioversion: str
831
832
    :param softwareversion: Software version, 10.x.y.zzzz. Can be guessed.
833
    :type softwareversion: str
834
835
    :param altsw: Radio software release, if not the same as OS.
836
    :type altsw: str
837
838
    :param temp: If file we write to is temporary. Default is False.
839
    :type temp: bool
840
841
    :param sdk: If we specifically want SDK images. Default is False.
842
    :type sdk: bool
843
    """
844 5
    radioversion = return_radio_version(osversion, radioversion)
845 5
    softwareversion, swc = return_sw_checked(softwareversion, osversion)
846 5
    del swc
847 5
    if altsw is not None:
848 5
        altsw, aswc = return_radio_sw_checked(altsw, radioversion)
849 5
        del aswc
850 5
    baseurl = utilities.create_base_url(softwareversion)
851 5
    oses, cores, radios = textgenerator.url_gen(osversion, radioversion, softwareversion)
852 5
    if altsw is not None:
853 5
        del radios
854 5
        dbks, cors, radios = textgenerator.url_gen(osversion, radioversion, altsw)
855 5
        del dbks
856 5
        del cors
857 5
    avlty = networkutils.availability(baseurl)
858 5
    oses, cores = linkgen_sdk(sdk, oses, cores)
859 5
    prargs = (softwareversion, osversion, radioversion, oses, cores, radios, avlty, False, None, temp, altsw)
860 5
    lthr = threading.Thread(target=textgenerator.write_links, args=prargs)
861 5
    lthr.start()
862
863
864 5
def clean_swrel(swrelset):
865
    """
866
    Clean a list of software release lookups.
867
868
    :param swrelset: List of software releases.
869
    :type swrelset: set(str)
870
    """
871 5
    for i in swrelset:
872 5
        if i != "SR not in system" and i is not None:
873 5
            swrelease = i
874 5
            break
875
    else:
876 5
        swrelease = ""
877 5
    return swrelease
878
879
880 5
def autolookup_logger(record, out):
881
    """
882
    Write autolookup results to file.
883
884
    :param record: The file to log to.
885
    :type record: str
886
887
    :param out: Output block.
888
    :type out: str
889
    """
890 5
    with open(record, "a") as rec:
891 5
        rec.write("{0}\n".format(out))
892
893
894 5
def autolookup_printer(out, avail, log=False, quiet=False, record=None):
895
    """
896
    Print autolookup results, logging if specified.
897
898
    :param out: Output block.
899
    :type out: str
900
901
    :param avail: Availability. Can be "Available" or "Unavailable".
902
    :type avail: str
903
904
    :param log: If we're logging to file.
905
    :type log: bool
906
907
    :param quiet: If we only note available entries.
908
    :type quiet: bool
909
910
    :param record: If we're logging, the file to log to.
911
    :type record: str
912
    """
913 5
    if not quiet:
914 5
        avail = "Available"  # force things
915 5
    if avail.lower() == "available":
916 5
        if log:
917 5
            lthr = threading.Thread(target=autolookup_logger, args=(record, out))
918 5
            lthr.start()
919 5
        print(out)
920
921
922 5
def autolookup_output_sql(osversion, swrelease, avail, sql=False):
923
    """
924
    Add OS to SQL database.
925
926
    :param osversion: OS version.
927
    :type osversion: str
928
929
    :param swrelease: Software release.
930
    :type swrelease: str
931
932
    :param avail: "Unavailable" or "Available".
933
    :type avail: str
934
935
    :param sql: If we're adding this to our SQL database.
936
    :type sql: bool
937
    """
938 5
    if sql:
939 5
        sqlutils.prepare_sw_db()
940 5
        if not sqlutils.check_exists(osversion, swrelease):
941 5
            sqlutils.insert(osversion, swrelease, avail.lower())
942
943
944 5
def autolookup_output(osversion, swrelease, avail, avpack, sql=False):
945
    """
946
    Prepare autolookup block, and add to SQL database.
947
948
    :param osversion: OS version.
949
    :type osversion: str
950
951
    :param swrelease: Software release.
952
    :type swrelease: str
953
954
    :param avail: "Unavailable" or "Available".
955
    :type avail: str
956
957
    :param avpack: Availabilities: alpha 1 and 2, beta 1 and 2, production.
958
    :type avpack: list(str)
959
960
    :param sql: If we're adding this to our SQL database.
961
    :type sql: bool
962
    """
963 5
    othr = threading.Thread(target=autolookup_output_sql, args=(osversion, swrelease, avail, sql))
964 5
    othr.start()
965 5
    avblok = "[{0}|{1}|{2}|{3}|{4}]".format(*avpack)
966 5
    out = "OS {0} - SR {1} - {2} - {3}".format(osversion, swrelease, avblok, avail)
967 5
    return out
968
969
970 5
def clean_barlist(cleanfiles, stoppers):
971
    """
972
    Remove certain bars from barlist based on keywords.
973
974
    :param cleanfiles: List of files to clean.
975
    :type cleanfiles: list(str)
976
977
    :param stoppers: List of keywords (i.e. bar names) to exclude.
978
    :type stoppers: list(str)
979
    """
980 5
    finals = [link for link in cleanfiles if all(word not in link for word in stoppers)]
981 5
    return finals
982
983
984 5
def prep_export_cchecker(files, npc, hwid, osv, radv, swv, upgrade=False, forced=None):
985
    """
986
    Prepare carrierchecker lookup links to write to file.
987
988
    :param files: List of file URLs.
989
    :type files: list(str)
990
991
    :param npc: MCC + MNC (ex. 302220).
992
    :type npc: int
993
994
    :param hwid: Device hardware ID.
995
    :type hwid: str
996
997
    :param osv: OS version.
998
    :type osv: str
999
1000
    :param radv: Radio version.
1001
    :type radv: str
1002
1003
    :param swv: Software release.
1004
    :type swv: str
1005
1006
    :param upgrade: Whether or not to use upgrade files. Default is false.
1007
    :type upgrade: bool
1008
1009
    :param forced: Force a software release. None to go for latest.
1010
    :type forced: str
1011
    """
1012 5
    if not upgrade:
1013 5
        newfiles = networkutils.carrier_query(npc, hwid, True, False, forced)
1014 5
        cleanfiles = newfiles[3]
1015
    else:
1016 5
        cleanfiles = files
1017 5
    osurls, coreurls, radiourls = textgenerator.url_gen(osv, radv, swv)
1018 5
    stoppers = ["8960", "8930", "8974", "m5730", "winchester"]
1019 5
    finals = clean_barlist(cleanfiles, stoppers)
1020 5
    return osurls, coreurls, radiourls, finals
1021
1022
1023 5
def export_cchecker(files, npc, hwid, osv, radv, swv, upgrade=False, forced=None):
1024
    """
1025
    Write carrierchecker lookup links to file.
1026
1027
    :param files: List of file URLs.
1028
    :type files: list(str)
1029
1030
    :param npc: MCC + MNC (ex. 302220).
1031
    :type npc: int
1032
1033
    :param hwid: Device hardware ID.
1034
    :type hwid: str
1035
1036
    :param osv: OS version.
1037
    :type osv: str
1038
1039
    :param radv: Radio version.
1040
    :type radv: str
1041
1042
    :param swv: Software release.
1043
    :type swv: str
1044
1045
    :param upgrade: Whether or not to use upgrade files. Default is false.
1046
    :type upgrade: bool
1047
1048
    :param forced: Force a software release. None to go for latest.
1049
    :type forced: str
1050
    """
1051 5
    if files:
1052 5
        osurls, coreurls, radiourls, finals = prep_export_cchecker(files, npc, hwid, osv, radv, swv, upgrade, forced)
1053 5
        textgenerator.write_links(swv, osv, radv, osurls, coreurls, radiourls, True, True, finals)
1054 5
        print("\nFINISHED!!!")
1055
    else:
1056 5
        print("CANNOT EXPORT, NO SOFTWARE RELEASE")
1057
1058
1059 5
def generate_blitz_links(files, osv, radv, swv):
1060
    """
1061
    Generate blitz URLs (i.e. all OS and radio links).
1062
    :param files: List of file URLs.
1063
    :type files: list(str)
1064
1065
    :param osv: OS version.
1066
    :type osv: str
1067
1068
    :param radv: Radio version.
1069
    :type radv: str
1070
1071
    :param swv: Software release.
1072
    :type swv: str
1073
    """
1074 5
    coreurls = [
1075
        utilities.create_bar_url(swv, "winchester.factory_sfi", osv),
1076
        utilities.create_bar_url(swv, "qc8960.factory_sfi", osv),
1077
        utilities.create_bar_url(swv, "qc8960.factory_sfi", osv),
1078
        utilities.create_bar_url(swv, "qc8960.factory_sfi_hybrid_qc8974", osv)
1079
    ]
1080 5
    radiourls = [
1081
        utilities.create_bar_url(swv, "m5730", radv),
1082
        utilities.create_bar_url(swv, "qc8960", radv),
1083
        utilities.create_bar_url(swv, "qc8960.wtr", radv),
1084
        utilities.create_bar_url(swv, "qc8960.wtr5", radv),
1085
        utilities.create_bar_url(swv, "qc8930.wtr5", radv),
1086
        utilities.create_bar_url(swv, "qc8974.wtr2", radv)
1087
    ]
1088 5
    return files + coreurls + radiourls
1089
1090
1091 5
def package_blitz(bardir, swv):
1092
    """
1093
    Package and verify a blitz package.
1094
1095
    :param bardir: Path to folder containing bar files.
1096
    :type bardir: str
1097
1098
    :param swv: Software version.
1099
    :type swv: str
1100
    """
1101 5
    print("\nCREATING BLITZ...")
1102 5
    barutils.create_blitz(bardir, swv)
1103 5
    print("\nTESTING BLITZ...")
1104 5
    zipver = archiveutils.zip_verify("Blitz-{0}.zip".format(swv))
1105 5
    if not zipver:
1106 5
        print("BLITZ FILE IS BROKEN")
1107 5
        raise SystemExit
1108
    else:
1109 5
        shutil.rmtree(bardir)
1110
1111
1112 5
def slim_preamble(appname):
1113
    """
1114
    Standard app name header.
1115
1116
    :param appname: Name of app.
1117
    :type appname: str
1118
    """
1119 5
    print("~~~{0} VERSION {1}~~~".format(appname.upper(), shortversion()))
1120
1121
1122 5
def standard_preamble(appname, osversion, softwareversion, radioversion, altsw=None):
1123
    """
1124
    Standard app name, OS, radio and software (plus optional radio software) print block.
1125
1126
    :param appname: Name of app.
1127
    :type appname: str
1128
1129
    :param osversion: OS version, 10.x.y.zzzz. Required.
1130
    :type osversion: str
1131
1132
    :param radioversion: Radio version, 10.x.y.zzzz. Can be guessed.
1133
    :type radioversion: str
1134
1135
    :param softwareversion: Software release, 10.x.y.zzzz. Can be guessed.
1136
    :type softwareversion: str
1137
1138
    :param altsw: Radio software release, if not the same as OS.
1139
    :type altsw: str
1140
    """
1141 5
    slim_preamble(appname)
1142 5
    print("OS VERSION: {0}".format(osversion))
1143 5
    print("OS SOFTWARE VERSION: {0}".format(softwareversion))
1144 5
    print("RADIO VERSION: {0}".format(radioversion))
1145 5
    if altsw is not None:
1146 5
        print("RADIO SOFTWARE VERSION: {0}".format(altsw))
1147
1148
1149 5
def questionnaire_device(message=None):
1150
    """
1151
    Get device from questionnaire.
1152
    """
1153 5
    message = "DEVICE (XXX100-#): " if message is None else message
1154 5
    device = input(message)
1155 5
    if not device:
1156 5
        print("NO DEVICE SPECIFIED!")
1157 5
        decorators.enter_to_exit(True)
1158 5
        if not getattr(sys, 'frozen', False):
1159 5
            raise SystemExit
1160 5
    return device
1161
1162
1163 5
def verify_gpg_credentials():
1164
    """
1165
    Read GPG key/pass from file, verify if incomplete.
1166
    """
1167 5
    gpgkey, gpgpass = gpgutils.gpg_config_loader()
1168 5
    if gpgkey is None or gpgpass is None:
1169 5
        print("NO PGP KEY/PASS FOUND")
1170 5
        cont = utilities.s2b(input("CONTINUE (Y/N)?: "))
1171 5
        if cont:
1172 5
            gpgkey = verify_gpg_key(gpgkey)
1173 5
            gpgpass, writebool = verify_gpg_pass(gpgpass)
1174 5
            gpgpass2 = gpgpass if writebool else None
1175 5
            gpgutils.gpg_config_writer(gpgkey, gpgpass2)
1176
        else:
1177 5
            gpgkey = None
1178 5
    return gpgkey, gpgpass
1179
1180
1181 5
def verify_gpg_key(gpgkey=None):
1182
    """
1183
    Verify GPG key.
1184
1185
    :param gpgkey: Key, use None to take from input.
1186
    :type gpgkey: str
1187
    """
1188 5
    if gpgkey is None:
1189 5
        gpgkey = input("PGP KEY (0x12345678): ")
1190 5
        if not gpgkey.startswith("0x"):
1191 5
            gpgkey = "0x{0}".format(gpgkey)   # add preceding 0x
1192 5
    return gpgkey
1193
1194
1195 5
def verify_gpg_pass(gpgpass=None):
1196
    """
1197
    Verify GPG passphrase.
1198
1199
    :param gpgpass: Passphrase, use None to take from input.
1200
    :type gpgpass: str
1201
    """
1202 5
    if gpgpass is None:
1203 5
        gpgpass = getpass.getpass(prompt="PGP PASSPHRASE: ")
1204 5
        writebool = utilities.s2b(input("SAVE PASSPHRASE (Y/N)?:"))
1205
    else:
1206 5
        writebool = False
1207 5
    return gpgpass, writebool
1208
1209
1210 5
def bulk_hash(dirs, compressed=True, deleted=True, radios=True, hashdict=None):
1211
    """
1212
    Hash files in several folders based on flags.
1213
1214
    :param dirs: Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
1215
    :type dirs: list(str)
1216
1217
    :param compressed: Whether to hash compressed files. True by default.
1218
    :type compressed: bool
1219
1220
    :param deleted: Whether to delete uncompressed files. True by default.
1221
    :type deleted: bool
1222
1223
    :param radios: Whether to hash radio autoloaders. True by default.
1224
    :type radios: bool
1225
1226
    :param hashdict: Dictionary of hash rules, in ~\bbarchivist.ini.
1227
    :type hashdict: dict({str: bool})
1228
    """
1229 5
    print("HASHING LOADERS...")
1230 5
    utilities.cond_check(hashutils.verifier, utilities.def_args(dirs), [hashdict], radios, compressed, deleted)
1231
1232
1233 5
def bulk_verify(dirs, compressed=True, deleted=True, radios=True):
1234
    """
1235
    Verify files in several folders based on flags.
1236
1237
    :param dirs: Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
1238
    :type dirs: list(str)
1239
1240
    :param compressed: Whether to hash compressed files. True by default.
1241
    :type compressed: bool
1242
1243
    :param deleted: Whether to delete uncompressed files. True by default.
1244
    :type deleted: bool
1245
1246
    :param radios: Whether to hash radio autoloaders. True by default.
1247
    :type radios: bool
1248
    """
1249 5
    gpgkey, gpgpass = verify_gpg_credentials()
1250 5
    if gpgpass is not None and gpgkey is not None:
1251 5
        print("VERIFYING LOADERS...")
1252 5
        print("KEY: {0}".format(gpgkey))
1253 5
        restargs = [gpgkey, gpgpass, True]
1254 5
        utilities.cond_check(gpgutils.gpgrunner, utilities.def_args(dirs), restargs, radios, compressed, deleted)
1255
1256
1257 5
def enn_ayy(quant):
1258
    """
1259
    Cheeky way to put a N/A placeholder for a string.
1260
1261
    :param quant: What to check if it's None.
1262
    :type quant: str
1263
    """
1264 5
    return "N/A" if quant is None else quant
1265
1266
1267 5
def generate_workfolder(folder=None):
1268
    """
1269
    Check if a folder exists, make it if it doesn't, set it to home if None.
1270
1271
    :param folder: Folder to check.
1272
    :type folder: str
1273
    """
1274 5
    folder = utilities.dirhandler(folder, os.getcwd())
1275 5
    if folder is not None and not os.path.exists(folder):
1276 5
        os.makedirs(folder)
1277 5
    return folder
1278
1279
1280 5
def info_header(afile, osver, radio=None, software=None, device=None):
1281
    """
1282
    Write header for info file.
1283
1284
    :param afile: Open file to write to.
1285
    :type afile: File object
1286
1287
    :param osver: OS version, required for both types.
1288
    :type osver: str
1289
1290
    :param radio: Radio version, required for QNX.
1291
    :type radio: str
1292
1293
    :param software: Software release, required for QNX.
1294
    :type software: str
1295
1296
    :param device: Device type, required for Android.
1297
    :type device: str
1298
    """
1299 5
    afile.write("OS: {0}\n".format(osver))
1300 5
    if device:
1301 5
        afile.write("Device: {0}\n".format(enn_ayy(device)))
1302
    else:
1303 5
        afile.write("Radio: {0}\n".format(enn_ayy(radio)))
1304 5
        afile.write("Software: {0}\n".format(enn_ayy(software)))
1305 5
    afile.write("{0}\n".format("~"*40))
1306
1307
1308 5
def prep_info(filepath, osver, device=None):
1309
    """
1310
    Prepare file list for new-style info file.
1311
1312
    :param filepath: Path to folder to analyze.
1313
    :type filepath: str
1314
1315
    :param osver: OS version, required for both types.
1316
    :type osver: str
1317
1318
    :param device: Device type, required for Android.
1319
    :type device: str
1320
    """
1321 5
    fileext = ".zip" if device else ".7z"
1322 5
    files = os.listdir(filepath)
1323 5
    absfiles = [os.path.join(filepath, x) for x in files if x.endswith((fileext, ".exe"))]
1324 5
    fname = os.path.join(filepath, "!{0}_OSINFO!.txt".format(osver))
1325 5
    return fname, absfiles
1326
1327
1328 5
def make_info(filepath, osver, radio=None, software=None, device=None):
1329
    """
1330
    Create a new-style info (names, sizes and hashes) file.
1331
1332
    :param filepath: Path to folder to analyze.
1333
    :type filepath: str
1334
1335
    :param osver: OS version, required for both types.
1336
    :type osver: str
1337
1338
    :param radio: Radio version, required for QNX.
1339
    :type radio: str
1340
1341
    :param software: Software release, required for QNX.
1342
    :type software: str
1343
1344
    :param device: Device type, required for Android.
1345
    :type device: str
1346
    """
1347 5
    fname, absfiles = prep_info(filepath, osver, device)
1348 5
    with open(fname, "w") as afile:
1349 5
        info_header(afile, osver, radio, software, device)
1350 5
        for indx, file in enumerate(absfiles):
1351 5
            write_info(file, indx, len(absfiles), afile)
1352
1353
1354 5
def write_info(infile, index, filecount, outfile):
1355
    """
1356
    Write a new-style info (names, sizes and hashes) file.
1357
1358
    :param infile: Path to file whose name, size and hash are to be written.
1359
    :type infile: str
1360
1361
    :param index: Which file index out of the list of files we're writing.
1362
    :type index: int
1363
1364
    :param filecount: Total number of files we're to write; for excluding terminal newline.
1365
    :type filecount: int
1366
1367
    :param outfile: Open (!!!) file handle. Output file.
1368
    :type outfile: str
1369
    """
1370 5
    fsize = os.stat(infile).st_size
1371 5
    outfile.write("File: {0}\n".format(os.path.basename(infile)))
1372 5
    outfile.write("\tSize: {0} ({1})\n".format(fsize, utilities.fsizer(fsize)))
1373 5
    outfile.write("\tHashes:\n")
1374 5
    outfile.write("\t\tMD5: {0}\n".format(hashutils.hashlib_hash(infile, hashlib.md5()).upper()))
1375 5
    outfile.write("\t\tSHA1: {0}\n".format(hashutils.hashlib_hash(infile, hashlib.sha1()).upper()))
1376 5
    outfile.write("\t\tSHA256: {0}\n".format(hashutils.hashlib_hash(infile, hashlib.sha256()).upper()))
1377 5
    outfile.write("\t\tSHA512: {0}\n".format(hashutils.hashlib_hash(infile, hashlib.sha512()).upper()))
1378 5
    if index != filecount - 1:
1379 5
        outfile.write("\n")
1380
1381
1382 5
def bulk_info(dirs, osv, compressed=True, deleted=True, radios=True, rad=None, swv=None, dev=None):
1383
    """
1384
    Generate info files in several folders based on flags.
1385
1386
    :param dirs: Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
1387
    :type dirs: list(str)
1388
1389
    :param osver: OS version, required for both types.
1390
    :type osver: str
1391
1392
    :param compressed: Whether to hash compressed files. True by default.
1393
    :type compressed: bool
1394
1395
    :param deleted: Whether to delete uncompressed files. True by default.
1396
    :type deleted: bool
1397
1398
    :param radios: Whether to hash radio autoloaders. True by default.
1399
    :type radios: bool
1400
1401
    :param rad: Radio version, required for QNX.
1402
    :type rad: str
1403
1404
    :param swv: Software release, required for QNX.
1405
    :type swv: str
1406
1407
    :param dev: Device type, required for Android.
1408
    :type dev: str
1409
    """
1410 5
    print("GENERATING INFO FILES...")
1411 5
    restargs = [osv, rad, swv, dev]
1412
    utilities.cond_check(make_info, utilities.def_args(dirs), restargs, radios, compressed, deleted)
1413