def setup_next_run(self, now):
        new_run_time = self.next_run
        schedule_type = int(utils.setting("schedule_interval"))

        if self.next_run <= now:
            if schedule_type == 0:
                new_run_time = now + SECONDS_PER_HOUR
            else:
                hour_of_day = int(utils.setting("schedule_time")[0:2])

                delay_map = {
                    1: 24,
                    2: 3 * 24,
                    3: 7 * 24
                }

                dt = datetime.datetime.fromtimestamp(now).replace(hour=hour_of_day)
                dt += datetime.timedelta(hours=delay_map[schedule_type])
                new_run_time = time.mktime(dt.timetuple())

        if new_run_time != self.next_run:
            self.next_run = new_run_time
            next_run = datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')
            utils.show_notification(utils.l10n(30050) % next_run)
            utils.log("Scheduler will run again on " + next_run)
 def setup(self):
     if self.is_enabled():
         #scheduler was turned on, find next run time
         utils.log("Scheduler enabled, finding next run time")
         self.next_run = 0
         self.setup_next_run(time.time())
         utils.log("Scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
示例#3
0
  def __init__(self, authorize_url):
      
    # save window resolution to arrange the text fields an QR code
    screenx = self.getWidth()
    screeny = self.getHeight()
    utils.log('Screen resolution: %dx%d' % (screenx, screeny), xbmc.LOGDEBUG)
    # Show Dialog with Dropbox Authorization URL

    res_qr_code = [0,0] # resolution of the QR-code image.
    # Show QR-Code Dropbox Authorization URL (source code from qr-code.py from service.linuxwhatelse.notify)
    if PIL_AVAILABLE:
        tmp_dir = os.path.join(utils.data_dir()) # tmp_dir has to exist
        tmp_file = os.path.join(tmp_dir, 'dropbox-auth-qr-code.png')
        # Create the QR-code image and save it to temp direcotry
        qr = qrcode.main.QRCode(box_size=40, border=2)
        qr.add_data(authorize_url)
        qr.make(fit=True)
        img = qr.make_image()
        img.save(tmp_file)
        # Show the QR-Code in Kodi
        # http://www.programcreek.com/python/example/84322/xbmcgui.getCurrentWindowId
        utils.log('Add control image with %dx%d at (%d,%d)' % (screeny/2, screeny/2, 100, 100), xbmc.LOGDEBUG)
        res_qr_code = [screeny/4, screeny/4] # TODO: the image is displayed bigger than the desired size. Find out why.
        image = xbmcgui.ControlImage(100, 100, res_qr_code[0], res_qr_code[1], tmp_file)
        self.addControl(image)
    else:
        # The PIL module isn't available so we inform the user about it
        utils.showNotification(utils.getString(32102), utils.getString(32201))

    # Print the Information text below the QR code
    self.addControl(xbmcgui.ControlLabel(x=100, y=(100+res_qr_code[1]+ 50), width=screenx, height=25, label=utils.getString(32704), textColor='0xFFFFFFFF'))
    self.addControl(xbmcgui.ControlLabel(x=100, y=(100+res_qr_code[1]+100), width=screenx, height=25, label=authorize_url, textColor='0xFFFFFFFF'))
    self.addControl(xbmcgui.ControlLabel(x=100, y=(100+res_qr_code[1]+150), width=screenx, height=25, label=utils.getString(32705), textColor='0xFFFFFFFF'))

    # this shows the window on the screen
    self.show()
示例#4
0
    PIL_AVAILABLE = True
except ImportError:
    PIL_AVAILABLE = False
import qrcode    

import resources.utils as utils


# parse input arguments
if len(sys.argv) == 5:#
    ADDON_TARGET_ID = sys.argv[1] # id of the calling addon
    SETTINGNAME_TARGET = sys.argv[2] # name of the settings field where the output is written to
    DROPBOX_APP_KEY = sys.argv[3]
    DROPBOX_APP_SECRET = sys.argv[4]
else:
    utils.log('expecting 5 input arguments for Target Addon Id, Setting Name, Dropbox App key and secret. Received %d:' % len(sys.argv), xbmc.LOGERROR)
    utils.log(str(sys.argv), xbmc.LOGNOTICE)
    utils.showNotification(utils.getString(32102), utils.getString(32202))
    sys.exit(1)
        

# Define a class for the Dialog to show the URL
class MyClass(xbmcgui.WindowDialog):
  # Opening a xbmcgui.Window does not work, since the open settings dialog prevents this (http://forum.kodi.tv/showthread.php?tid=262100&pid=2263074#pid2263074)
  # Use xbmcgui.WindowDiaolog to be able to show the QR-code image
  def __init__(self, authorize_url):
      
    # save window resolution to arrange the text fields an QR code
    screenx = self.getWidth()
    screeny = self.getHeight()
    utils.log('Screen resolution: %dx%d' % (screenx, screeny), xbmc.LOGDEBUG)
def run_converter(silent=False):
    utils.log("Running the converter")

    if utils.setting("address_selection") == '0':
        host_address = BroadwayFinder.find_hostname()
    else:
        host_address = utils.setting("ip_address")

    utils.log("Using Broadway host-address %s" % host_address)

    try:
        connection = Connector(host_address, utils.setting("pin"))
        utils.log("Connection with Broadway is established")
    except Exception as e:
        utils.log("Failed connecting to Broadway, caused by " + str(e),
                  loglevel=xbmc.LOGERROR)
        if not silent:
            xbmcgui.Dialog().ok(utils.l10n(30010), utils.l10n(30101))
            utils.open_settings()

        return

    path = xbmc.translatePath(utils.setting("target_directory"))
    utils.log("Creating Channels & EPG below %s" % path)

    if not os.path.exists(path):
        utils.log(
            "Aborting conversion: The output directory '%s' doesn't exist." %
            path,
            loglevel=xbmc.LOGERROR)
        if not silent:
            xbmcgui.Dialog().ok(utils.l10n(30010), utils.l10n(30102))
            utils.open_settings()
        return

    converter = Converter(connection)

    utils.show_notification(utils.l10n(30060) % __channels_file_name)
    utils.log("Writing '%s'" % __channels_file_name)
    converter.write_channels_m3u(path + os.sep + __channels_file_name)

    utils.show_notification(utils.l10n(30060) % __epg_file_name)
    utils.log("Writing '%s'" % __epg_file_name)
    converter.write_epg(path + os.sep + __epg_file_name)

    utils.show_notification(utils.l10n(30100))
示例#6
0
def restore_ipsw(fresh_ipsw, ipsw_path):
    processor = ipsw.fetch_processor(firmware_bundle)

    if fresh_ipsw:
        utils.log('------------RESTORE-BEGINNING------------', False)
        utils.log('Restoring freshly created custom IPSW', is_verbose)
    else:
        utils.log('Inferius Restore Log', False)
        utils.log('Checking if IPSW is custom...', False)
        is_stock = ipsw.verify_ipsw(device_identifier, args.version[0], ipsw_path, buildid, is_verbose)
        if is_stock:
            utils.log('[ERROR] IPSW is stock!\nExiting...', False)
            sys.exit()

    if args.update:
        keep_data = True
    else:
        keep_data = False

    device_check = input('Is your device is connected in Pwned DFU mode with signature checks removed? [Y/N]: ')
    utils.log(f'Is your device is connected in Pwned DFU mode with signature checks removed? [Y/N]: {device_check}', False)

    if not 'y' in device_check.lower():
        utils.log('[ERROR] Specified device is not in pwndfu!\nExiting...', is_verbose)
        sys.exit()

    lsusb = subprocess.run('./resources/bin/lsusb', stdout=subprocess.PIPE, universal_newlines=True, shell=True)
    utils.log(lsusb.stdout, False)

    if not 'Apple Mobile Device (DFU Mode)' in lsusb.stdout:
        utils.log('[ERROR] Specified device is not in pwndfu!\nExiting...', is_verbose)
        sys.exit()

    os.makedirs('work/ipsw', exist_ok=True)
    utils.log('Fetching some required info...', True)
    restore.save_blobs(device_identifier, firm_bundle_number, board_configs, downgrade_10, is_verbose)

    utils.log('Extracting iBSS and iBEC from custom IPSW...', True)
    ibss_path, ibec_path = ipsw.extract_bootchain(ipsw_path, firmware_bundle, firm_bundle_number, is_verbose)

    utils.log('Signing iBSS and iBEC with SHSH blob...', True)
    restore.sign_bootchain(ibss_path, ibec_path, is_verbose)

    utils.log('Preparations done! Beginning restore...', True)
    if downgrade_10:
        ipsw.fetch_1033_sepbb(device_identifier, args.version[0], is_verbose)

    restore.send_bootchain(processor, is_verbose)
    futurerestore = restore.restore(ipsw_path, ipsw.is_cellular(device_identifier), keep_data, downgrade_10, is_verbose)
    if not futurerestore:
        sys.exit()
    else:
        utils.cleanup(True)

    utils.log('Done.\nExiting...', True)
示例#7
0
def create_ipsw():
    utils.log('Verifying IPSW. This may take a while, please wait...', True)
    is_stock = ipsw.verify_ipsw(device_identifier, args.version[0], args.ipsw[0], buildid, is_verbose)
    if not is_stock:
        sys.exit(f'[ERROR] IPSW {args.ipsw[0]} is not verified! Redownload your IPSW, and try again.\nExiting...')

    utils.log('IPSW verified! Extracting IPSW...', True)
    ipsw.extract_ipsw(args.ipsw[0], is_verbose)

    utils.log('IPSW extracted! Patching bootchain...', True)
    patch.patch_bootchain(firmware_bundle, firm_bundle_number, buildid, is_verbose)

    utils.log('Bootchain patched! Grabbing latest LLB and iBoot to put into custom IPSW...', True)
    ipsw.grab_latest_llb_iboot(device_identifier, args.version[0], firmware_bundle, firm_bundle_number, is_verbose)

    utils.log('Packing everything into custom IPSW. This may take a while, please wait...', True)
    ipsw_name = ipsw.make_ipsw(firmware_bundle, is_verbose)

    utils.log(f'Done!\nCustom IPSW at: {ipsw_name}', True)

    if not args.restore:
        utils.cleanup(True)

    return ipsw_name
示例#8
0
        ipsw.fetch_1033_sepbb(device_identifier, args.version[0], is_verbose)

    restore.send_bootchain(processor, is_verbose)
    futurerestore = restore.restore(ipsw_path, ipsw.is_cellular(device_identifier), keep_data, downgrade_10, is_verbose)
    if not futurerestore:
        sys.exit()
    else:
        utils.cleanup(True)

    utils.log('Done.\nExiting...', True)

if not args.ipsw:
    sys.exit(parser.print_help(sys.stderr))

if args.device:
    utils.log('Inferius Log', False)
    device_identifier = args.device[0].lower()
    device_identifier = device_identifier.replace('p', 'P')
    utils.log(f'[INFO] Device: {device_identifier}', False)
else:
    sys.exit(parser.print_help(sys.stderr))

if args.verbose:
    is_verbose = True
else:
    is_verbose = False

if args.version:
    version_str = args.version[0]
    version_str = version_str.split('.')
    unsupported_major_versions = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '14']
def run_converter(silent=False):
    utils.log("Running the converter")

    if utils.setting("address_selection") == '0':
        host_address = BroadwayFinder.find_hostname()
    else:
        host_address = utils.setting("ip_address")

    utils.log("Using Broadway host-address %s" % host_address)

    try:
        connection = Connector(host_address, utils.setting("pin"))
        utils.log("Connection with Broadway is established")
    except Exception as e:
        utils.log("Failed connecting to Broadway, caused by " + str(e), loglevel=xbmc.LOGERROR)
        if not silent:
            xbmcgui.Dialog().ok(utils.l10n(30010), utils.l10n(30101))
            utils.open_settings()

        return

    path = xbmc.translatePath(utils.setting("target_directory"))
    utils.log("Creating Channels & EPG below %s" % path)

    if not os.path.exists(path):
        utils.log("Aborting conversion: The output directory '%s' doesn't exist." % path, loglevel=xbmc.LOGERROR)
        if not silent:
            xbmcgui.Dialog().ok(utils.l10n(30010), utils.l10n(30102))
            utils.open_settings()
        return

    converter = Converter(connection)

    utils.show_notification(utils.l10n(30060) % __channels_file_name)
    utils.log("Writing '%s'" % __channels_file_name)
    converter.write_channels_m3u(path + os.sep + __channels_file_name)

    utils.show_notification(utils.l10n(30060) % __epg_file_name)
    utils.log("Writing '%s'" % __epg_file_name)
    converter.write_epg(path + os.sep + __epg_file_name)

    utils.show_notification(utils.l10n(30100))