예제 #1
0
 def replace_icon_in_exe(self, exe_path):
     icon_setting = self.get_setting('icon')
     exe_icon_setting = self.get_setting('exe_icon')
     icon_path = (exe_icon_setting.value
                  if exe_icon_setting.value else icon_setting.value)
     if icon_path:
         p = PEFile(exe_path)
         p.replace_icon(os.path.join(self.project_dir(), icon_path))
         p.write(exe_path)
         p = None
예제 #2
0
from pepy.pe import PEFile
from pycns import save_icns
import sys

if __name__ == '__main__':
    if len(sys.argv) < 4 or len(sys.argv) > 5:
        print('image_tools <command> <args>\n'
              '  commands: save_icns input_file output_file\n'
              '            replace_icon input_exe icon_path [output_path]')
        sys.exit()

    command = sys.argv[1]
    file1, file2 = sys.argv[2:4]

    output_path = file1
    if len(sys.argv) == 5:
        output_path = sys.argv[4]

    if command == 'save_icns':
        save_icns(file1, file2)
    elif command == 'replace_icon':
        p = PEFile(file1)
        p.replace_icon(file2)
        p.write(output_path)