Example #1
0
def can_update_cal(path):
    """ Check if cal can be updated by checking for required fields. """
    try:
        calstat = os.stat(path)
    except Exception as exception:
        safe_print("Warning - os.stat('%s') failed: %s" %
                   tuple(safe_unicode(s) for s in (path, exception)))
        return False
    if not path in cals or cals[path].mtime != calstat.st_mtime:
        try:
            cal = CGATS.CGATS(path)
        except (IOError, CGATS.CGATSInvalidError,
                CGATS.CGATSInvalidOperationError, CGATS.CGATSKeyError,
                CGATS.CGATSTypeError, CGATS.CGATSValueError) as exception:
            if path in cals:
                del cals[path]
            safe_print("Warning - couldn't process CGATS file '%s': %s" %
                       tuple(safe_unicode(s) for s in (path, exception)))
        else:
            if cal.queryv1("DEVICE_CLASS") == "DISPLAY" and not None in \
               (cal.queryv1("TARGET_WHITE_XYZ"),
             cal.queryv1("TARGET_GAMMA"),
             cal.queryv1("BLACK_POINT_CORRECTION"),
             cal.queryv1("QUALITY")):
                cals[path] = cal
    return path in cals and cals[path].mtime == calstat.st_mtime
Example #2
0
def stop(inp):
    try:
        pkt = Packet(PacketType.stop, destination=int(inp[0]))
    except (IndexError, ValueError):
        pkt = Packet(PacketType.stop)

    pkt.send()
    safe_print(pkt)
Example #3
0
def ignore_heartbeats(inp=[]):
    global ignore_heartbeats
    try:
        ignore_heartbeats = ("yes" in inp[0]) or ("on" in inp[0])
    except IndexError:
        ignore_heartbeats = not ignore_heartbeats

    safe_print("Ignoring heartbeats: %r" % ignore_heartbeats)
Example #4
0
def stop(inp):
    try:
        pkt = Packet(PacketType.stop, destination=int(inp[0]))
    except (IndexError, ValueError):
        pkt = Packet(PacketType.stop)

    pkt.send()
    safe_print(pkt)
Example #5
0
def ignore_heartbeats(inp=[]):
    global ignore_heartbeats
    try:
        ignore_heartbeats = ("yes" in inp[0]) or ("on" in inp[0])
    except IndexError:
        ignore_heartbeats = not ignore_heartbeats
    
    safe_print("Ignoring heartbeats: %r" % ignore_heartbeats)
Example #6
0
def connect(inp=[]):
    if bluetooth.serial_port.isOpen():
        safe_print("Bluetooth is already connected.")
    else:

        if len(inp) == 0:
            which = None
        else:
            which = inp[0]

        bluetooth.start(which, handle_pkt, safe_print)
Example #7
0
def add_dispcal_options_to_cal(cal, options_dispcal):
    # Add dispcal options to cal
    options_dispcal = quote_nonoption_args(options_dispcal)
    try:
        cgats = CGATS.CGATS(cal)
        cgats[0].add_section(
            "ARGYLL_DISPCAL_ARGS",
            " ".join(options_dispcal).encode("UTF-7", "replace"))
        return cgats
    except Exception as exception:
        safe_print(safe_unicode(traceback.format_exc()))
Example #8
0
def connect(inp=[]):
    if bluetooth.serial_port.isOpen():
        safe_print("Bluetooth is already connected.")
    else:
            
        if len(inp) == 0:
            which = None
        else:
            which = inp[0]
            
        bluetooth.start(which, handle_pkt, safe_print)
Example #9
0
 def process_data(self, data):
     if data[0] == "echo" and len(data) > 1:
         linecount = self.console.GetNumberOfLines()
         lastline = self.console.GetLineText(linecount - 1)
         if lastline:
             self.add_text("\n")
         txt = " ".join(data[1:])
         safe_print(txt)
         self.add_text(txt + "\n")
         if lastline:
             self.add_text("> ")
         return "ok"
     return "invalid"
Example #10
0
def avail(which, inp):
    global availability

    old_val = availability[which]
    if inp[0] == "+" or inp[0] == "-":
        # If first character of first input is +, use +n notation to mark tube n as occupied
        num = tubenum(inp[1:])  # Get the tubenum with chars 1 through end of the first input
        if num == -1:
            safe_print(
                "! " + which + " availability invalid, one number between 0 and 3 expected with +n or -n notation"
            )
            return
        else:
            availability[which][num] = inp[0] == "+"
    else:
        # Using bitmask mode
        if len(inp) != 4:
            safe_print("! " + which + " availability invalid, one 4-digit bitmask expected in bitmask mode")
            return
        else:
            for ch in inp:
                if ch != "0" and ch != "1":
                    print_safe("! " + which + " availability invalid, only 0 and 1 expected in bitmask mode")
                    return
            availability[which] = boolstr_to_list(inp)

    safe_print(which + " updated from 0b%s to 0b%s" % (list_to_boolstr(old_val), list_to_boolstr(availability[which])))

    typ = PacketType.supply_availability if which is "Supply" else PacketType.storage_availability
    pkt = Packet(typ, list_to_int(availability[which]), destination=0)
    pkt.send()
    safe_print(pkt)
Example #11
0
def add_options_to_ti3(ti3, options_dispcal=None, options_colprof=None):
    # Add dispcal and colprof options to ti3
    try:
        cgats = CGATS.CGATS(ti3)
        if options_colprof:
            options_colprof = quote_nonoption_args(options_colprof)
            cgats[0].add_section(
                "ARGYLL_COLPROF_ARGS",
                " ".join(options_colprof).encode("UTF-7", "replace"))
        if options_dispcal and 1 in cgats:
            options_dispcal = quote_nonoption_args(options_dispcal)
            cgats[1].add_section(
                "ARGYLL_DISPCAL_ARGS",
                " ".join(options_dispcal).encode("UTF-7", "replace"))
        return cgats
    except Exception as exception:
        safe_print(safe_unicode(traceback.format_exc()))
Example #12
0
 def OnClose(self, event):
     # So we can send_command('close') ourselves without prematurely exiting
     # the wx main loop
     while self.busy:
         wx.Yield()
         sleep(.05)
     # Hide first (looks nicer)
     self.Hide()
     try:
         with open(self.historyfilename, "wb") as historyfile:
             for command in self.history:
                 if command:
                     historyfile.write(
                         safe_str(command, "UTF-8") + os.linesep)
     except EnvironmentError as exception:
         safe_print("Warning - couldn't write history file:", exception)
     self.listening = False
     # Need to use CallAfter to prevent hang under Windows if minimized
     wx.CallAfter(self.Destroy)
Example #13
0
def main():
    funcs['connect']()
    
    while True:
        try:
            inp = raw_input("> ").split()
            cmd = inp[0]
            inp = inp[1:] # input remaining after command
            
            if cmd == "exit":
                break
            elif cmd in funcs:
                funcs[cmd](inp)
            else:
                safe_print("! Unknown command `" + cmd + "`. Inputs: " + repr(inp)) 
            
        # Makes Ctrl-C clear the input like I'm used to from bash/zsh
        except KeyboardInterrupt:
            print #newline
            continue
Example #14
0
def main():
    funcs["connect"]()

    while True:
        try:
            inp = raw_input("> ").split()
            cmd = inp[0]
            inp = inp[1:]  # input remaining after command

            if cmd == "exit":
                break
            elif cmd in funcs:
                funcs[cmd](inp)
            else:
                safe_print("! Unknown command `" + cmd + "`. Inputs: " + repr(inp))

        # Makes Ctrl-C clear the input like I'm used to from bash/zsh
        except KeyboardInterrupt:
            print  # newline
            continue
Example #15
0
    def _print_formated_message(self, msgObj, is_receiving=True):
        type = msgObj.get("type")
        sender = msgObj.get("sender")
        receiver = msgObj.get("receiver")
        data = msgObj.get("data")
        ts = msgObj.get("timestamp")

        if type != "ice-candidate" and type != "ice-candidate_hotspot":
            if is_receiving is True:
                safe_print( " [x] Message received.      Type:" + \
                    "{0: <30}".format(type) + \
                    "{0: <15}".format(sender) + \
                    ">>" + \
                    "{0: >15}".format(receiver) )
            else:
                safe_print( " [*] Message sent.          Type:" + \
                    "{0: <30}".format(type) + \
                    "{0: <15}".format(sender) + \
                    ">>" + \
                    "{0: >15}".format(receiver) )

        return type, sender, receiver, data, ts
Example #16
0
def cal_to_vcgt(cal, return_cgats=False):
    """ 
	Create a vcgt tag from calibration data.
	
	cal must refer to a valid Argyll CAL file and can be a CGATS instance 
	or a filename.
	
	"""
    if not isinstance(cal, CGATS.CGATS):
        try:
            cal = CGATS.CGATS(cal)
        except (IOError, CGATS.CGATSInvalidError,
                CGATS.CGATSInvalidOperationError, CGATS.CGATSKeyError,
                CGATS.CGATSTypeError, CGATS.CGATSValueError) as exception:
            safe_print("Warning - couldn't process CGATS file '%s': %s" %
                       tuple(safe_unicode(s) for s in (cal, exception)))
            return None
    required_fields = ("RGB_I", "RGB_R", "RGB_G", "RGB_B")
    data_format = cal.queryv1("DATA_FORMAT")
    if data_format:
        for field in required_fields:
            if not field in list(data_format.values()):
                if debug: safe_print("[D] Missing required field:", field)
                return None
        for field in list(data_format.values()):
            if not field in required_fields:
                if debug: safe_print("[D] Unknown field:", field)
                return None
    entries = cal.queryv(required_fields)
    if len(entries) < 1:
        if debug:
            safe_print("[D] No entries found in calibration", cal.filename)
        return None
    vcgt = ICCP.VideoCardGammaTableType("", "vcgt")
    vcgt.update({
        "channels": 3,
        "entryCount": len(entries),
        "entrySize": 2,
        "data": [[], [], []]
    })
    for n in entries:
        for i in range(3):
            vcgt.data[i].append(entries[n][i + 1] * 65535.0)
    if return_cgats:
        return vcgt, cal
    return vcgt
Example #17
0
def avail(which, inp):
    global availability

    old_val = availability[which]
    if inp[0] == '+' or inp[0] == '-':
        # If first character of first input is +, use +n notation to mark tube n as occupied
        num = tubenum(
            inp[1:]
        )  # Get the tubenum with chars 1 through end of the first input
        if num == -1:
            safe_print(
                "! " + which +
                " availability invalid, one number between 0 and 3 expected with +n or -n notation"
            )
            return
        else:
            availability[which][num] = (inp[0] == '+')
    else:
        # Using bitmask mode
        if len(inp) != 4:
            safe_print(
                "! " + which +
                " availability invalid, one 4-digit bitmask expected in bitmask mode"
            )
            return
        else:
            for ch in inp:
                if ch != '0' and ch != '1':
                    print_safe(
                        "! " + which +
                        " availability invalid, only 0 and 1 expected in bitmask mode"
                    )
                    return
            availability[which] = boolstr_to_list(inp)

    safe_print(
        which + " updated from 0b%s to 0b%s" %
        (list_to_boolstr(old_val), list_to_boolstr(availability[which])))

    typ = PacketType.supply_availability if which is 'Supply' else PacketType.storage_availability
    pkt = Packet(typ, list_to_int(availability[which]), destination=0)
    pkt.send()
    safe_print(pkt)
Example #18
0
def resume(inp):
    pkt = Packet(PacketType.resume)
    pkt.send()
    safe_print(pkt)
Example #19
0
    def __init__(self):
        SimpleTerminal.__init__(
            self,
            None,
            wx.ID_ANY,
            lang.getstr("scripting-client"),
            start_timer=False,
            pos=(getcfg("position.scripting.x"),
                 getcfg("position.scripting.y")),
            size=(getcfg("size.scripting.w"), getcfg("size.scripting.h")),
            consolestyle=wx.TE_CHARWRAP | wx.TE_MULTILINE | wx.TE_PROCESS_ENTER
            | wx.TE_RICH | wx.VSCROLL | wx.NO_BORDER,
            show=False,
            name="scriptingframe")
        self.SetIcons(
            config.get_icon_bundle([256, 48, 32, 16],
                                   appname + "-scripting-client"))
        self.console.SetForegroundColour("#EEEEEE")
        self.console.SetDefaultStyle(wx.TextAttr("#EEEEEE"))

        self.busy = False
        self.commands = []
        self.history = []
        self.historyfilename = os.path.join(
            confighome, config.appbasename + "-scripting-client.history")
        if os.path.isfile(self.historyfilename):
            try:
                with open(self.historyfilename) as historyfile:
                    for line in historyfile:
                        self.history.append(
                            safe_unicode(line, "UTF-8").rstrip("\r\n"))
            except EnvironmentError as exception:
                safe_print("Warning - couldn't read history file:", exception)
        # Always have empty selection at bottom
        self.history.append("")
        self.historypos = len(self.history) - 1

        self.overwrite = False

        # Determine which application we should connect to by default (if any)
        self.conn = None
        scripting_hosts = self.get_scripting_hosts()

        self.sizer.Layout()
        if sys.platform != "darwin":
            # Under Mac OS X, the transparency messes up the window shadow if
            # there is another window's border behind
            self.SetTransparent(240)

        self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Unbind(wx.EVT_CHAR_HOOK)
        self.console.Unbind(wx.EVT_KEY_DOWN, self.console)
        self.console.Bind(wx.EVT_KEY_DOWN, self.key_handler)
        self.console.Bind(wx.EVT_TEXT_COPY, self.copy_text_handler)
        self.console.Bind(wx.EVT_TEXT_PASTE, self.paste_text_handler)
        if sys.platform == "darwin":
            # Under Mac OS X, pasting text via the context menu isn't catched
            # by EVT_TEXT_PASTE. TODO: Implement custom context menu.
            self.console.Bind(wx.EVT_CONTEXT_MENU, lambda event: None)

        if scripting_hosts:
            self.add_text("> getscriptinghosts" + "\n")
            for host in scripting_hosts:
                self.add_text(host + "\n")
            ip_port = scripting_hosts[0].split()[0]
            self.add_text("> connect " + ip_port + "\n")
            self.connect_handler(ip_port)
Example #20
0
def supply(inp):
    if len(inp) != 1:
        safe_print("! Supply availability invalid, one argument expected")
        return
    else:
        avail("Supply", inp[0])
Example #21
0
def storage(inp):
    if len(inp) != 1:
        safe_print("! Storage availability invalid, one argument expected")
        return
    else:
        avail("Storage", inp[0])
Example #22
0
def extract_cal_from_profile(profile,
                             out_cal_path=None,
                             raise_on_missing_cal=True,
                             prefer_cal=False):
    """ Extract calibration from 'targ' tag in profile or vcgt as fallback """

    white = False

    # Check if calibration is included in TI3
    targ = profile.tags.get("targ", profile.tags.get("CIED"))
    if isinstance(targ, ICCP.Text):
        cal = extract_cal_from_ti3(targ)
        if cal:
            check = cal
            get_cgats = CGATS.CGATS
            arg = cal
    else:
        cal = None
    if not cal:
        # Convert calibration information from embedded WCS profile
        # (if present) to VideCardFormulaType if the latter is not present
        if (isinstance(profile.tags.get("MS00"), ICCP.WcsProfilesTagType)
                and not "vcgt" in profile.tags):
            profile.tags["vcgt"] = profile.tags["MS00"].get_vcgt()

        # Get the calibration from profile vcgt
        check = isinstance(profile.tags.get("vcgt"), ICCP.VideoCardGammaType)
        get_cgats = vcgt_to_cal
        arg = profile

    if not check:
        if raise_on_missing_cal:
            raise Error(lang.getstr("profile.no_vcgt"))
        else:
            return False
    else:
        try:
            cgats = get_cgats(arg)
        except (IOError, CGATS.CGATSError) as exception:
            raise Error(lang.getstr("cal_extraction_failed"))
    if (cal and not prefer_cal
            and isinstance(profile.tags.get("vcgt"), ICCP.VideoCardGammaType)):
        # When vcgt is nonlinear, prefer it
        # Check for video levels encoding
        if cgats.queryv1("TV_OUTPUT_ENCODING") == "YES":
            black, white = (16, 235)
        else:
            output_enc = cgats.queryv1("OUTPUT_ENCODING")
            if output_enc:
                try:
                    black, white = (float(v) for v in output_enc.split())
                except (TypeError, ValueError):
                    white = False
        cgats = vcgt_to_cal(profile)
        if white and (black, white) != (0, 255):
            safe_print("Need to un-scale vcgt from video levels (%s..%s)" %
                       (black, white))
            # Need to un-scale video levels
            data = cgats.queryv1("DATA")
            if data:
                safe_print("Un-scaling vcgt from video levels (%s..%s)" %
                           (black, white))
                encoding_mismatch = False
                # For video encoding the extra bits of
                # precision are created by bit shifting rather
                # than scaling, so we need to scale the fp
                # value to account for this
                oldmin = (black / 256.0) * (65536 / 65535.)
                oldmax = (white / 256.0) * (65536 / 65535.)
                for entry in data.values():
                    for column in "RGB":
                        v_old = entry["RGB_" + column]
                        lvl = round(v_old * (65535 / 65536.) * 256, 2)
                        if lvl < round(black, 2) or lvl > round(white, 2):
                            # Can't be right. Metadata says it's video encoded,
                            # but clearly exceeds the encoding range.
                            safe_print("Warning: Metadata claims video levels "
                                       "(%s..%s) but vcgt value %s exceeds "
                                       "encoding range. Using values as-is." %
                                       (round(black, 2), round(white, 2), lvl))
                            encoding_mismatch = True
                            break
                        v_new = colormath.convert_range(
                            v_old, oldmin, oldmax, 0, 1)
                        entry["RGB_" + column] = min(max(v_new, 0), 1)
                    if encoding_mismatch:
                        break
                if encoding_mismatch:
                    cgats = vcgt_to_cal(profile)
                # Add video levels hint to CGATS
                elif (black, white) == (16, 235):
                    cgats[0].add_keyword("TV_OUTPUT_ENCODING", "YES")
                else:
                    cgats[0].add_keyword(
                        "OUTPUT_ENCODING",
                        " ".join(str(v) for v in (black, white)))
            else:
                safe_print("Warning - no un-scaling applied - no "
                           "calibration data!")
    if out_cal_path:
        cgats.write(out_cal_path)
    return cgats
Example #23
0
def vrmlfile2x3dfile(vrmlpath=None,
                     x3dpath=None,
                     html=True,
                     embed=False,
                     view=False,
                     force=False,
                     cache=True,
                     worker=None,
                     gui=True):
    """ Convert VRML to HTML. Output is written to <vrmlfilename>.x3d.html
	unless you set x3dpath to desired output path, or False to be prompted
	for an output path. """
    while not vrmlpath or not os.path.isfile(vrmlpath):
        if not gui:
            if not vrmlpath or vrmlpath.startswith("--"):
                safe_print("No filename given.")
            else:
                safe_print("%r is not a file." % vrmlpath)
            return False
        if not wx.GetApp():
            app = BaseApp(0)
        defaultDir, defaultFile = config.get_verified_path("last_vrml_path")
        dlg = wx.FileDialog(None,
                            lang.getstr("file.select"),
                            defaultDir=defaultDir,
                            defaultFile=defaultFile,
                            wildcard=lang.getstr("filetype.vrml") +
                            "|*.vrml;*.vrml.gz;*.wrl.gz;*.wrl;*.wrz",
                            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        dlg.Center(wx.BOTH)
        result = dlg.ShowModal()
        vrmlpath = dlg.GetPath()
        dlg.Destroy()
        if result != wx.ID_OK:
            return
        config.setcfg("last_vrml_path", vrmlpath)
        config.writecfg(module="VRML-to-X3D-converter",
                        options=("last_vrml_path", ))
    filename, ext = os.path.splitext(vrmlpath)
    if x3dpath is None:
        x3dpath = filename + ".x3d"
    if x3dpath:
        dirname = os.path.dirname(x3dpath)
    while not x3dpath or not waccess(dirname, os.W_OK):
        if not gui:
            if not x3dpath:
                safe_print("No HTML output filename given.")
            else:
                safe_print("%r is not writable." % dirname)
            return False
        if not wx.GetApp():
            app = BaseApp(0)
        if x3dpath:
            defaultDir, defaultFile = os.path.split(x3dpath)
        else:
            defaultFile = os.path.basename(filename) + ".x3d"
        dlg = wx.FileDialog(None,
                            lang.getstr("error.access_denied.write", dirname),
                            defaultDir=defaultDir,
                            defaultFile=defaultFile,
                            wildcard=lang.getstr("filetype.x3d") + "|*.x3d",
                            style=wx.SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.Center(wx.BOTH)
        result = dlg.ShowModal()
        dlg.Destroy()
        if result != wx.ID_OK:
            return
        x3dpath = dlg.GetPath()
        dirname = os.path.dirname(x3dpath)
    vrmlpath, x3dpath = [safe_unicode(path) for path in (vrmlpath, x3dpath)]
    if sys.platform == "win32":
        vrmlpath = make_win32_compatible_long_path(vrmlpath)
        x3dpath = make_win32_compatible_long_path(x3dpath)
    if html:
        finalpath = x3dpath + ".html"
        if sys.platform == "win32":
            finalpath = make_win32_compatible_long_path(finalpath)
            x3dpath = finalpath[:-5]
    else:
        finalpath = x3dpath
    if worker:
        worker.clear_cmd_output()
        worker.start(
            lambda result: show_result_dialog(result,
                                              wx.GetApp().GetTopWindow())
            if isinstance(result, Exception
                          ) else result and view and launch_file(finalpath),
            x3dom.vrmlfile2x3dfile,
            wargs=(vrmlpath, x3dpath, html, embed, force, cache, worker),
            progress_title=lang.getstr("vrml_to_x3d_converter"),
            progress_start=1,
            resume=worker.progress_wnd
            and worker.progress_wnd.IsShownOnScreen(),
            fancy=False)
    else:
        result = x3dom.vrmlfile2x3dfile(vrmlpath, x3dpath, html, embed, force,
                                        cache, None)
        if not isinstance(result, Exception) and result:
            if view:
                launch_file(finalpath)
        else:
            return False
    return True
Example #24
0
            if (placeholder == "${TRC}" and not result
                    and "${TRC_GAMMA}" in placeholders2data):
                default = "BT.1886"
            else:
                default = ""
            placeholders2data[placeholder] = result.groups(
            )[0] if result else default
        if result and placeholder == "${COLS}":
            templatename = "uniformity"

    # backup original report
    shutil.copy2(report_path,
                 "%s.%s" % (report_path, strftime("%Y-%m-%d_%H-%M-%S")))

    create(report_path, placeholders2data, pack, templatename)


if __name__ == "__main__":
    initcfg()
    lang.init()
    if not sys.argv[1:]:
        safe_print("Update existing report(s) with current template files.")
        safe_print("Usage: %s report1.html [report2.html...]" %
                   os.path.basename(sys.argv[0]))
    else:
        for arg in sys.argv[1:]:
            try:
                update(arg)
            except (IOError, OSError) as exception:
                safe_print(exception)
Example #25
0
def main():
    if "--help" in sys.argv[1:] or (not sys.argv[1:] and not gui):
        safe_print("Convert VRML file to X3D")
        safe_print("Author: Florian Hoech, licensed under the GPL version 3")
        safe_print("Usage: %s [OPTION]... FILE..." %
                   os.path.basename(sys.argv[0]))
        safe_print("The output is written to FILENAME.x3d(.html)")
        safe_print("")
        safe_print("  --embed      Embed viewer components in HTML instead of "
                   "referencing them")
        safe_print("  --force      Force fresh download of viewer components")
        safe_print("  --no-cache   Don't use viewer components cache (only "
                   "uses existing cache if")
        safe_print("               embedding components, can be overridden "
                   "with --force)")
        if gui:
            safe_print("  --no-gui     Don't use GUI (console mode)")
        safe_print("  --no-html    Don't generate HTML file")
        safe_print("  --view       View the generated file (if no GUI)")
        if not gui:
            safe_print("  --batch      Don't pause after processing")
        safe_print("  FILE         Filename of VRML file to convert")
        if gui:
            return
    if gui:
        config.initcfg("VRML-to-X3D-converter")
        lang.init()
        lang.update_defaults()
    cache = not "--no-cache" in sys.argv[1:]
    embed = "--embed" in sys.argv
    force = "--force" in sys.argv
    html = not "--no-html" in sys.argv[1:]
    if not gui:
        result = None
        view = "--view" in sys.argv[1:]
        for arg in sys.argv[1:]:
            if not arg.startswith("--"):
                result = vrmlfile2x3dfile(safe_unicode(arg),
                                          html=html,
                                          embed=embed,
                                          view=view,
                                          force=force,
                                          cache=cache,
                                          gui=gui)
        if result is None:
            safe_print("No filename given.")
        if sys.stdout.isatty() and not "--batch" in sys.argv[1:]:
            input("Press RETURN to exit")
        sys.exit(int(not result))
    else:
        view = not "--no-view" in sys.argv[1:]
        app = BaseApp(0)
        app.TopWindow = VRML2X3DFrame(html, embed, view, force, cache)
        if sys.platform == "darwin":
            app.TopWindow.init_menubar()
        wx.CallLater(1, _main, app)
        app.MainLoop()
Example #26
0
def handle_pkt(pkt):
    if not ignore_heartbeats or pkt.type != bluetooth.PacketType.heartbeat:
        safe_print(pkt)
Example #27
0
 def send(self):
     if (serial_port.isOpen()):
         serial_port.write(self.to_data())
     else:
         safe_print("! Serial connection isn't open")
Example #28
0
def supply(inp):
    if len(inp) != 1:
        safe_print("! Supply availability invalid, one argument expected")
        return
    else:
        avail("Supply", inp[0])
Example #29
0
def resume(inp):
    pkt = Packet(PacketType.resume)
    pkt.send()
    safe_print(pkt)
Example #30
0
def storage(inp):
    if len(inp) != 1:
        safe_print("! Storage availability invalid, one argument expected")
        return
    else:
        avail("Storage", inp[0])
Example #31
0
def handle_pkt(pkt):
    if not ignore_heartbeats or pkt.type != bluetooth.PacketType.heartbeat:
        safe_print(pkt)
Example #32
0
 def send(self):
     if serial_port.isOpen():
         serial_port.write(self.to_data())
     else:
         safe_print("! Serial connection isn't open")