Exemplo n.º 1
0
  def do_list(self,args):
    rc=0
    result=None

    if not args.id:
      rc,result=self.list_by_type(args.save_type)
    else:
      if not args.save_type:
        args.save_type=self.filesystem.get_json_filename_type(args.id)
      if not args.save_type:
        return 1,"Unable to determine type of id %s" % args.id
      filename=self.filesystem.get_json_filename_for_type(args.id,args.save_type)
      data=tts.load_json_file(filename)
      rc,result=self.list_item(data,filename,args.id)
    return rc,result
Exemplo n.º 2
0
    def do_export(self, args):
        filename = None
        if args.output:
            if os.path.isdir(args.output):
                filename = os.path.join(args.output, args.id + ".pak")
            else:
                filename = args.output
        else:
            filename = args.id + ".pak"

        data = None
        json_filename = None
        if not args.save_type:
            args.save_type = self.filesystem.get_json_filename_type(args.id)
        if not args.save_type:
            return 1, "Unable to determine type of id %s" % args.id

        json_filename = self.filesystem.get_json_filename_for_type(
            args.id, args.save_type)

        if not json_filename:
            return 1, "Unable to find filename for id %s (wrong -s/-w/-c specified?)" % args.id
        data = tts.load_json_file(json_filename)
        if not data:
            return 1, "Unable to load data for file %s" % json_filename

        save = tts.Save(savedata=data,
                        filename=json_filename,
                        ident=args.id,
                        save_type=args.save_type,
                        filesystem=self.filesystem)
        if not save.isInstalled:
            if not args.download:
                return 1, "Unable to find all urls required by %s. Rerun with -d to try and download them or open it within TTS.\n%s" % (
                    args.id, save)
            else:
                tts.logger().info("Downloading missing files...")
                successful = save.download()
                if successful:
                    tts.logger().info("Files downloaded successfully.")
                else:
                    return 1, "Some files failed to download"
        if os.path.isfile(filename) and not args.force:
            return 1, "%s already exists. Please specify another file or use '-f'" % filename
        tts.logger().info("Exporting json file %s to %s" % (args.id, filename))
        save.export(filename)
        # TODO: exception handling
        return 0, "Exported %s to %s" % (args.id, filename)
Exemplo n.º 3
0
  def do_export(self,args):
    filename=None
    if args.output:
      if os.path.isdir(args.output):
        filename=os.path.join(args.output,args.id+".pak")
      else:
        filename=args.output
    else:
      filename=args.id+".pak"

    data=None
    json_filename=None
    if not args.save_type:
      args.save_type=self.filesystem.get_json_filename_type(args.id)
    if not args.save_type:
      return 1,"Unable to determine type of id %s" % args.id

    json_filename=self.filesystem.get_json_filename_for_type(args.id,args.save_type)

    if not json_filename:
      return 1, "Unable to find filename for id %s (wrong -s/-w/-c specified?)" % args.id
    data=tts.load_json_file(json_filename)
    if not data:
      return 1, "Unable to load data for file %s" % json_filename

    save=tts.Save(savedata=data,
                  filename=json_filename,
                  ident=args.id,
                  save_type=args.save_type,
                  filesystem=self.filesystem)
    if not save.isInstalled:
      if not args.download:
        return 1, "Unable to find all urls required by %s. Rerun with -d to try and download them or open it within TTS.\n%s" % (args.id,save)
      else:
        tts.logger().info("Downloading missing files...")
        successful = save.download()
        if successful:
          tts.logger().info("Files downloaded successfully.")
        else:
          return 1, "Some files failed to download"
    if os.path.isfile(filename) and not args.force:
      return 1,"%s already exists. Please specify another file or use '-f'" % filename
    tts.logger().info("Exporting json file %s to %s" % (args.id,filename))
    save.export(filename)
    # TODO: exception handling
    return 0,"Exported %s to %s" % (args.id,filename)
Exemplo n.º 4
0
 def file_list_has_changed(self, now):
     if not now:
         return
     ident = self.file_store[now[0]]
     filename = self.filesystem.get_json_filename_for_type(
         ident, self.save_type.get())
     data = tts.load_json_file(filename)
     # TODO: error handling
     self.save = tts.Save(savedata=data,
                          ident=ident,
                          filename=filename,
                          save_type=tts.SaveType(self.save_type.get()),
                          filesystem=self.filesystem)
     if self.save.isInstalled:
         self.status_label.config(text="All files found.")
     else:
         self.status_label.config(
             text="Some cache files missing - check details on list page.")
     self.file_list.event_generate("<<SelectionChange>>")
Exemplo n.º 5
0
 def file_list_has_changed(self, now):
     if not now:
         return
     ident = self.file_store[now[0]]
     filename = self.filesystem.get_json_filename_for_type(ident, self.save_type.get())
     data = tts.load_json_file(filename)
     # TODO: error handling
     self.save = tts.Save(
         savedata=data,
         ident=ident,
         filename=filename,
         save_type=tts.SaveType(self.save_type.get()),
         filesystem=self.filesystem,
     )
     if self.save.isInstalled:
         self.status_label.config(text="All files found.")
     else:
         self.status_label.config(text="Some cache files missing - check details on list page.")
     self.file_list.event_generate("<<SelectionChange>>")