def runner(self):
     if platform_name() in self.platforms_dictionary:
         exec(self.platforms_dictionary[platform_name()]["open"])
         self.x = "Tray is opened"
         time.sleep(self.t)
         exec(self.platforms_dictionary[platform_name()]["close"])
     else:
         self.x = "Sorry, no OS found"
Esempio n. 2
0
def release():  # Function to run whatever release mech the user selected
    global release_tested
    global arduino_enabled

    if arduino_enabled:
        print("Releasing with arduino")
        arduino.write(b'0')  # Release
        time.sleep(5)
        arduino.write(b'1')  # Hold

    if DiskDrive_enabled:
        print(platform_name())
        if platform_name() in platforms_dictionary:
            print('Releasing with Disk Drive')
            exec(platforms_dictionary[platform_name()]["open"])
Esempio n. 3
0
    def GetCoreModule(self, platform=None) -> (object, str):

        if not platform:
            platform = platform_name(
            )  # Get the name of the victim Operating System

        BDCoreModule = None

        # Check if the module is installed
        if platform in self.modules.keys():

            # Try to load the module
            try:
                print("Loading {}".format(self.modules[platform]))
                BDCoreModule = __import__(
                    self.modules[platform],
                    fromlist=[''])  # Return a handle to the module

            except Exception as exc:

                raise RuntimeError("Failed to import BDCoreModule: {}".format(
                    exc))  # Importing failed

        else:
            BDCoreModule = __import__(
                self.modules["Default"],
                fromlist=[''])  # Return handle to default module

        return (BDCoreModule, platform)
Esempio n. 4
0
def platform_open(str):
    """Open specified file using your window manager's preferred application"""
    name = platform_name()[0]
    if name == "Linux":
        os.system("gnome-open " + str)
    elif name == "Windows":
        os.system("start " + str)
    else:
        os.system("open " + str)
Esempio n. 5
0
def radar_dependencies():
    dependencies = [
        'nose==1.3.7',
        'pyyaml==3.11',
        'mock==1.3.0',
    ]

    if platform_name() == 'Windows':
        dependencies.append('pypiwin32==219')

    return dependencies
Esempio n. 6
0
 def get_os_type():
     bsds = ['Darwin', 'FreeBSD', 'NetBSD', 'OpenBSD']
     platform = platform_name()
     platform = 'BSD' if platform in bsds else platform
     return 'Unknown' if platform not in Platform.SUPPORTED_OS_TYPES else platform
Esempio n. 7
0
 def get_platform_type():
     unixes = ['Linux', 'Darwin', 'FreeBSD', 'NetBSD', 'OpenBSD']
     platform = platform_name()
     return 'UNIX' if platform in unixes else platform
               },
    "Darwin":  {
                "open" : 'system("drutil tray open")',
                "close": 'system("drutil tray closed")'
               },
    "Linux":   {
                "open" : 'system("eject cdrom")',
                "close": 'system("eject -t cdrom")'
               },
    "NetBSD":  {
                "open" : 'system("eject cd")',
                "close": 'system("eject -t cd")'
               },
    "FreeBSD": {
                "open" : 'system("sudo cdcontrol eject")',
                "close": 'system("sudo cdcontrol close")'
               }
}

print(platform_name())

if platform_name() in platforms_dictionary:
    print("Abrindo")
    exec(platforms_dictionary[platform_name()]["open"])
    time.sleep(2)
    print("Fechando")
    time.sleep(2)
    exec(platforms_dictionary[platform_name()]["close"])
else:
    print("S.O não suportado")
Esempio n. 9
0
def release_test():
    global release_tested
    global arduino_enabled
    global DiskDrive_enabled
    global arduino
    global teaseEnable

    if not arduino_enabled and not DiskDrive_enabled:
        messagebox.showwarning(
            '', 'No Release Methid selected\nYou may still start the program')

    if teaseEnable and not arduino_enabled:
        messagebox.showwarning(
            '', 'Arduino must be enabled in order to use the arduino tease')
        return

# Find arduino on first run
    if arduino_enabled and not release_tested:
        arduino_ports = [
            p.device for p in serial.tools.list_ports.comports() if 'USB-SER'
            in p.description  # may need tweaking to match new arduinos
        ]
        if not arduino_ports:
            messagebox.showwarning(
                '',
                'No Arduino Found, check cable and that drivers are installed')
        if len(arduino_ports) > 1:
            messagebox.showwarning('',
                                   'Multiple Arduinos found, using the first')

        arduino = serial.Serial(arduino_ports[0])

        print(arduino)

    if arduino_enabled:

        print("Trying Arduino")

        # Jog Servo to positions
        messagebox.showwarning(
            '', 'press ok to\n Move Servo to HOLD KEY Position')
        arduino.write(b'1')  # Hold
        messagebox.showwarning(
            '', 'press ok to\nMove Servo to RELEASE KEY Position')
        arduino.write(b'0')  # Release
        if teaseEnable:
            messagebox.showwarning(
                '', 'press ok to\nMove Servo to TEASE Position')
            arduino.write(b'2')  # Tease
        messagebox.showwarning(
            '', 'press ok to\nMove Servo back to HOLD KEY Position')
        arduino.write(b'1')  # Hold


# Pop open disk drive

    if DiskDrive_enabled:
        print("Trying Disk Drive")
        print(platform_name())
        if platform_name() in platforms_dictionary:
            messagebox.showwarning('', 'Press OK to open Disk Drive')
            exec(platforms_dictionary[platform_name()]["open"])
        else:
            messagebox.showwarning(
                '',
                'OS not supported\n Open an issue on github and we can try!!')

    release_tested = True