Esempio n. 1
0
 def _set_execute_permissions_(self, destdir):
     """
     Apparently permissions aren't preserved in zip files, so I need to
     manually make sure that the executable has the +x bit set. This section
     is completely unnecessary on Windows, and Windows emulators should leave
     _executable_files_ empty
     """
     for x_file in self._executable_files_:
         log_file("Setting executable permission on %s" % x_file)
         # Get the full path
         file_path = os.path.join(destdir,x_file)
         # Taken from StackOverflow answer: 
         # http://stackoverflow.com/questions/12791997/how-do-you-do-a-simple-chmod-x-from-within-python
         st = os.stat(file_path)
         os.chmod(file_path, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
Esempio n. 2
0
 def _set_execute_permissions_(self):
     """
     Apparently permissions aren't preserved in zip files, so I need to
     manually make sure that the executable has the +x bit set. This section
     is completely unnecessary on Windows, and Windows emulators should leave
     _executable_files_ empty
     """
     for x_file in self._executable_files_:
         log_file("Setting executable permission on %s" % x_file)
         # Get the full path
         file_path = os.path.join(destdir, x_file)
         # Taken from StackOverflow answer:
         # http://stackoverflow.com/questions/12791997/how-do-you-do-a-simple-chmod-x-from-within-python
         st = os.stat(file_path)
         os.chmod(file_path,
                  st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
Esempio n. 3
0
 def _download_(self):
     emulators_dir = filesystem_helper.downloaded_emulators_directory()
     zips_dir = filesystem_helper.downloaded_zips_directory()
     # Make sure the directorys exists
     filesystem_helper.create_directory_if_needed(emulators_dir)
     filesystem_helper.create_directory_if_needed(zips_dir)
     url = self._download_location_
     zip_path = os.path.join(filesystem_helper.downloaded_zips_directory(),os.path.basename(url))
     # If we have downloaded (and therefore extracted) the zip file before,
     # there is no reason to do it again
     if os.path.exists(zip_path):
         log_file("Found zip file %s" % os.path.basename(url))
     else:
         log_both("Downloading %s" % url)
         (downloaded_path,headers) = urllib.urlretrieve(url)
         log_both("Finished downloading %s" % url)
         shutil.copyfile(downloaded_path,zip_path)
         self._unzip_(downloaded_path,emulators_dir)
     self.location = os.path.join(emulators_dir,self._relative_exe_path_)
     self.directory = os.path.join(emulators_dir,self._directory_name_)
Esempio n. 4
0
 def _unzip_(self, file, destdir):
     log_file("Unzipping %s to %s" % (file, destdir))
     z = zipfile.ZipFile(file)
     for f in z.namelist():
         # Zipfiles store paths internally using a forward slash. If os.sep
         # is not a forward slash, then we will compute an incorrect path.
         # Fix that by replacing all forward slashes with backslashes if
         # os.sep is a backslash
         if os.sep == "\\" and "/" in f:
             destfile = os.path.join(destdir, f.replace("/", "\\"))
         else:
             destfile = os.path.join(destdir, f)
         if destfile.endswith(os.sep):
             if not os.path.exists(destfile):
                 os.makedirs(destfile)
         else:
             file = open(destfile, "wb")
             file.write(z.read(f))
             file.close()
     z.close()
     self._set_execute_permissions_()
Esempio n. 5
0
 def _download_(self):
     emulators_dir = filesystem_helper.downloaded_emulators_directory()
     zips_dir = filesystem_helper.downloaded_zips_directory()
     # Make sure the directorys exists
     filesystem_helper.create_directory_if_needed(emulators_dir)
     filesystem_helper.create_directory_if_needed(zips_dir)
     url = self._download_location_
     zip_path = os.path.join(filesystem_helper.downloaded_zips_directory(),
                             os.path.basename(url))
     # If we have downloaded (and therefore extracted) the zip file before,
     # there is no reason to do it again
     if os.path.exists(zip_path):
         log_file("Found zip file %s" % os.path.basename(url))
     else:
         log_both("Downloading %s" % url)
         (downloaded_path, headers) = urllib.urlretrieve(url)
         log_both("Finished downloading %s" % url)
         shutil.copyfile(downloaded_path, zip_path)
         self._unzip_(downloaded_path, emulators_dir)
     self.location = os.path.join(emulators_dir, self._relative_exe_path_)
     self.directory = os.path.join(emulators_dir, self._directory_name_)
Esempio n. 6
0
 def _unzip_(self,file,destdir):
     log_file("Unzipping %s to %s" % (file,destdir))
     z = zipfile.ZipFile(file)
     for f in z.namelist():
         # Zipfiles store paths internally using a forward slash. If os.sep
         # is not a forward slash, then we will compute an incorrect path.
         # Fix that by replacing all forward slashes with backslashes if
         # os.sep is a backslash
         if os.sep == "\\" and "/" in f:
             destfile = os.path.join(destdir,f.replace("/","\\"))
         else:
             destfile = os.path.join(destdir,f)
         if destfile.endswith(os.sep):
             if not os.path.exists(destfile):
                 os.makedirs(destfile)
         else:
             file = open(destfile,"wb")
             file.write(z.read(f))
             file.close()
     z.close()
     self._set_execute_permissions_(destdir)
Esempio n. 7
0
 def __check_for_user_supplied_bios__(self):
     # If the bios already exists, we don't need to do anything
     if os.path.exists(self.emulator_bios_location()):
         log_file("Found bios in emulator already")
         return
     if os.path.exists(self.user_supplied_bios_location()):
         # The user has given us a bios, we should copy the file to the 
         # correct location
         log_file("Found bios in ROMs directory, copying it to emulator location")
         shutil.copyfile(self.user_supplied_bios_location(),self.emulator_bios_location())
         return
     log_file("No bios found")
Esempio n. 8
0
 def __check_for_user_supplied_bios__(self):
     # If the bios already exists, we don't need to do anything
     if os.path.exists(self.emulator_bios_location()):
         log_file("Found bios in emulator already")
         return
     if os.path.exists(self.user_supplied_bios_location()):
         # The user has given us a bios, we should copy the file to the
         # correct location
         log_file(
             "Found bios in ROMs directory, copying it to emulator location"
         )
         shutil.copyfile(self.user_supplied_bios_location(),
                         self.emulator_bios_location())
         return
     log_file("No bios found")
Esempio n. 9
0
File: ice.py Progetto: rrfenton/Ice
        rom_manager = IceROMManager(shortcuts_manager)
        # Add the new ROMs in each folder to our Shortcut Manager
        rom_manager.sync_roms(roms)
        # Generate a new shortcuts.vdf file with all of the new additions
        shortcuts_manager.save()
        log_both("---Downloading grid images")
        grid_manager.update_user_images(user_id, roms)
    log_both("=========================Finished")


if __name__ == "__main__":
    try:
        main()
    except ConfigError as error:
        log_user("=========================Stopping\n")
        log_file("!!!Error was Users' fault. Don't worry about it")
        log_both("There was a problem with '%s' in config.txt" %
                 error.referenced_config)
        log_both(error.fix_instructions)
        log_file("!!!")
    except StandardError as error:
        log_both("####################################")
        log_both("An Error has occurred:")
        log_both(error)
        log_exception()
        log_both("####################################")
    # Keeps the console from closing (until the user hits enter) so they can
    # read any console output
    print ""
    print "Close the window, or hit enter to exit..."
    raw_input()
Esempio n. 10
0
File: ice.py Progetto: waytai/Ice
        rom_manager = IceROMManager(shortcuts_manager)
        # Add the new ROMs in each folder to our Shortcut Manager
        rom_manager.sync_roms(roms)
        # Generate a new shortcuts.vdf file with all of the new additions
        shortcuts_manager.save()
        if IceGridImageManager.should_download_images():
            log_both("---Downloading grid images")
            grid_manager.update_user_images(user_id,roms)
        else:
            log_both("Skipping 'Download Image' step")
    log_both("=========================Finished")
        
if __name__ == "__main__":
    try:
        main()
    except ConfigError as error:
        log_user("=========================Stopping\n")
        log_config_error(error)
        log_exception()
        log_file("!!!")
    except StandardError as error:
        log_both("####################################")
        log_both("An Error has occurred:")
        log_both(error)
        log_exception()
        log_both("####################################")
    # Keeps the console from closing (until the user hits enter) so they can
    # read any console output
    print ""
    print "Close the window, or hit enter to exit..."
    raw_input()
Esempio n. 11
0
File: ice.py Progetto: ch13696/Ice
        # Add the new ROMs in each folder to our Shortcut Manager
        rom_manager.sync_roms(roms)
        # Generate a new shortcuts.vdf file with all of the new additions
        shortcuts_manager.save()
        if IceGridImageManager.should_download_images():
            log_both("---Downloading grid images")
            grid_manager.update_user_images(user_id,roms)
        else:
            log_both("Skipping 'Download Image' step")
    log_both("=========================Finished")
        
if __name__ == "__main__":
    try:
        main()
    except ConfigError as error:
        log_user("=========================Stopping\n")
        log_file("!!!Error was Users' fault. Don't worry about it")
        log_both("There was a problem with '[%s] %s' in config.txt" % (error.section, error.key))
        log_both(error.fix_instructions)
        log_file("!!!")
    except StandardError as error:
        log_both("####################################")
        log_both("An Error has occurred:")
        log_both(error)
        log_exception()
        log_both("####################################")
    # Keeps the console from closing (until the user hits enter) so they can
    # read any console output
    print ""
    print "Close the window, or hit enter to exit..."
    raw_input()