unknown-cli 0.9.24__tar.gz → 0.9.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/PKG-INFO +1 -1
  2. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/PKG-INFO +1 -1
  3. unknown-cli-0.9.27/unknowncli/VERSION +1 -0
  4. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/commands/preflight.py +74 -60
  5. unknown-cli-0.9.24/unknowncli/VERSION +0 -1
  6. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/README.md +0 -0
  7. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/setup.cfg +0 -0
  8. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/setup.py +0 -0
  9. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/SOURCES.txt +0 -0
  10. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/dependency_links.txt +0 -0
  11. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/entry_points.txt +0 -0
  12. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/requires.txt +0 -0
  13. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknown_cli.egg-info/top_level.txt +0 -0
  14. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/__init__.py +0 -0
  15. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/__main__.py +0 -0
  16. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/commands/__init__.py +0 -0
  17. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/commands/project.py +0 -0
  18. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/commands/task.py +0 -0
  19. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/commands/unreal.py +0 -0
  20. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/data/.p4ignore.txt +0 -0
  21. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/set_registry_keys.py +0 -0
  22. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/set_url_handler.py +0 -0
  23. {unknown-cli-0.9.24 → unknown-cli-0.9.27}/unknowncli/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unknown-cli
3
- Version: 0.9.24
3
+ Version: 0.9.27
4
4
  Summary: Unknown Commandline Tool
5
5
  Home-page: UNKNOWN
6
6
  Author:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unknown-cli
3
- Version: 0.9.24
3
+ Version: 0.9.27
4
4
  Summary: Unknown Commandline Tool
5
5
  Home-page: UNKNOWN
6
6
  Author:
@@ -0,0 +1 @@
1
+ 0.9.27
@@ -10,10 +10,10 @@ from collections import OrderedDict
10
10
  from datetime import datetime
11
11
  from enum import Enum
12
12
  from P4 import P4, P4Exception
13
+ from psutil import process_iter
13
14
  from shutil import which
14
15
  from subprocess import CalledProcessError, check_output
15
16
  from typing import List, Optional
16
-
17
17
  from typer import confirm, Option, prompt, secho
18
18
  from rich.live import Live
19
19
  from rich.progress import Progress, BarColumn, MofNCompleteColumn, SpinnerColumn, TaskProgressColumn, TextColumn
@@ -104,10 +104,6 @@ custom_tool_list.append(
104
104
  CustomToolDef(
105
105
  name="Preflight and Commit - Full", command = pwsh_tool_exe,
106
106
  arguments = f"{pwsh_cmd_base} {base_cmd_full}"
107
- ),
108
- CustomToolDef(
109
- name="Preflight and Commit on Server - Quick", command = pwsh_tool_exe, add_separator_before = True,
110
- arguments = f"{pwsh_cmd_base} {base_cmd_quick} --use-server-submit"
111
107
  )
112
108
  ]
113
109
  )
@@ -389,6 +385,10 @@ def verify_changelist(change_obj, change_obj_list):
389
385
  abort(f"Selected changelist does not have any opened files: {changelist} ({client})")
390
386
  if not any([c for c in change_obj_list if c.client == client and c.change == changelist]):
391
387
  abort(f"Selected changelist not owned by current user: {changelist} ({client})")
388
+ describe_shelve = get_describe_shelve(changelist)[0]
389
+ for shelf_file in describe_shelve["depotFile"]:
390
+ if re.search("^\/\/[^\/]*\/[^\/]*\/Raw", shelf_file):
391
+ abort(f"Cannot preflight a CL containing Raw files.")
392
392
  return
393
393
 
394
394
 
@@ -409,6 +409,8 @@ def get_describe_shelve(shelve_changelist):
409
409
  def revert_file_in_default(depot_file, *extra_args):
410
410
  return p4.run_revert(*extra_args, "-c", "default", depot_file)
411
411
 
412
+ def revert_file_in_cl(depot_file, clnumber, *extra_args):
413
+ return p4.run_revert(*extra_args, "-c", clnumber, depot_file)
412
414
 
413
415
  def flush_file(depot_file):
414
416
  return p4.run_sync("-k", depot_file)
@@ -544,7 +546,7 @@ def get_script_path(script_file_name):
544
546
  abort(f"Failed to find script '{script_file_name}', post for help on Slack!")
545
547
 
546
548
 
547
- def get_shelve_preflight_build_id(shelve_changelist, type=PreflightType.FULL, stream="", find=False, print_output=True, abort_on_fail=True, submit_on_server=False):
549
+ def get_shelve_preflight_build_id(shelve_changelist, type=PreflightType.FULL, stream="", find=False, print_output=True, abort_on_fail=True, submit_on_server=True, content_only_build=False):
548
550
  cmd = [
549
551
  sys.executable,
550
552
  get_script_path("trigger_shelve_preflight.py"),
@@ -556,6 +558,8 @@ def get_shelve_preflight_build_id(shelve_changelist, type=PreflightType.FULL, st
556
558
  ["--shelve_stream", stream] if stream else []
557
559
  ) + (
558
560
  ["--submit_on_server"] if submit_on_server else []
561
+ ) + (
562
+ ["--content_only"] if content_only_build else []
559
563
  )
560
564
  build_id = ""
561
565
  try:
@@ -569,7 +573,7 @@ def get_shelve_preflight_build_id(shelve_changelist, type=PreflightType.FULL, st
569
573
  secho(e.output.decode("ascii"), fg="red")
570
574
  if abort_on_fail:
571
575
  abort(f"Failed to {'find' if find else 'trigger'} preflight.")
572
- if build_id:
576
+ if build_id and print_output:
573
577
  secho(f"Found TeamCity build id: {build_id}")
574
578
  return build_id
575
579
 
@@ -767,6 +771,13 @@ def move_open_files_to_default(shelve_changelist: str):
767
771
  reopen_changelist_to_default(shelve_changelist)
768
772
  return opened_file_list
769
773
 
774
+ def shelf_is_content_only(shelve_changelist: str) -> bool:
775
+ describe_shelve = get_describe_shelve(shelve_changelist)[0]
776
+ for shelf_file in describe_shelve["depotFile"]:
777
+ if re.search("/Source/", shelf_file):
778
+ return False
779
+ return True
780
+
770
781
  def commit(shelve_changelist: str):
771
782
  """
772
783
  Commit a shelve
@@ -819,16 +830,37 @@ def commit(shelve_changelist: str):
819
830
  return
820
831
 
821
832
 
833
+ def tailscale_is_connected() -> bool:
834
+ try:
835
+ result = check_output('tailscale status')
836
+ return True
837
+ except CalledProcessError as e:
838
+ return False
839
+
840
+
841
+ def editor_is_running():
842
+ for proc in process_iter(['name']):
843
+ if proc.info['name'] == "Subnautica2Editor.exe":
844
+ return True
845
+ return False
846
+
847
+
822
848
  def main(
823
849
  changelist: str = Option("", help="The changelist you own and want to preflight."),
824
850
  commit_on_success: Optional[bool] = Option(True, help="Commit the shelve on successful preflight."),
825
851
  type: PreflightType = Option(PreflightType.QUICK, help="The type of preflight to run."),
826
852
  p4v_config_type: P4VConfigType = Option(None, help="The command to use when running from P4V context menus."),
827
- use_server_submit: Optional[bool] = Option(False, help="If committing on successful preflight, should server side commit be used.")
853
+ use_server_submit: Optional[bool] = Option(True, help="If committing on successful preflight, should server side commit be used."),
854
+ verbose: Optional[bool] = Option(False, help="Enables extra debug output.")
828
855
  ):
829
856
  """
830
857
  Preflight a changelist
831
858
  """
859
+
860
+ # Check for Tailscale connection
861
+ if not "Tailscale" in os.environ["PATH"] or not tailscale_is_connected():
862
+ abort("In order to preflight you must be connected to Tailscale.")
863
+
832
864
  try:
833
865
  install_p4v_tools(p4v_config_type)
834
866
  except Exception as e:
@@ -840,62 +872,43 @@ def main(
840
872
  except Exception as e:
841
873
  abort(f"Failed to sync scripts; ask for help!\n{e}...")
842
874
 
843
- build_id = ""
844
- shelve_changelist = ""
845
- sorted_change_obj_list = get_sorted_change_obj_list()
846
- for shelve in [c for c in sorted_change_obj_list if c.is_shelved]:
847
- attempted_build_id = get_shelve_preflight_build_id(
848
- shelve.change, find=True, print_output=False, abort_on_fail=False
849
- )
850
- if not attempted_build_id:
851
- continue
875
+ # Check for editor, if running wait for it to be closed
876
+ if use_server_submit and editor_is_running():
877
+ secho("\nEditor is running, save your work and close it to continue..")
878
+ while editor_is_running():
879
+ time.sleep(1)
852
880
 
853
- build_json = get_teamcity_build_json(attempted_build_id)
854
- build_state = get_build_state(build_json)
855
- secho(f" Build state: {build_state}")
856
- if build_state in [BuildState.QUEUED, BuildState.RUNNING]:
857
- secho(f"Existing preflight in progress for shelve {shelve.change}...\n", fg="green", bold=True)
858
- build_id = attempted_build_id
859
- shelve_changelist = shelve.change
860
- break
861
- elif build_state == BuildState.FINISHED and is_build_success(build_json):
862
- if confirm(f"Shelve '{shelve.change}' was successful, do you want to commit it now?", prompt_suffix=""):
863
- commit(shelve.change)
864
- if changelist == shelve.change:
865
- secho("Requested shelve was committed; refresh P4V.", fg="green", bold=True)
866
- return
867
-
868
- # Get an updated change list in case some changes were submitted.
869
881
  sorted_change_obj_list = get_sorted_change_obj_list()
870
- if not build_id:
871
- secho("No preflight in progress. Triggering a new preflight.\n", bold=True)
872
- change_obj = None
873
- if changelist:
874
- change_obj = get_change_obj(changelist)
882
+ if changelist:
883
+ change_obj = get_change_obj(changelist)
884
+ else:
885
+ print_change_obj_list(sorted_change_obj_list)
886
+ chosen_index = prompt(f"\nSelect a changelist")
887
+ choice_count = len(sorted_change_obj_list)
888
+ if not chosen_index.isdigit() or not (int(chosen_index) in range(choice_count)):
889
+ abort("Invalid option.")
875
890
  else:
876
- print_change_obj_list(sorted_change_obj_list)
877
- chosen_index = prompt(f"\nSelect a changelist")
878
- choice_count = len(sorted_change_obj_list)
879
- if not chosen_index.isdigit() or not (int(chosen_index) in range(choice_count)):
880
- abort("Invalid option.")
881
- else:
882
- change_obj = sorted_change_obj_list[int(chosen_index)]
883
- verify_changelist(change_obj, sorted_change_obj_list)
884
- if get_opened_file_list(change_obj.change):
885
- shelve_changelist = attempt_shelve_changelist(change_obj.change)
886
- if use_server_submit:
887
- if not confirm(f"\nFiles are opened in CL {change_obj.change} and must be re-opened in default to submit on server. Re-open files?"):
888
- abort("Aborting preflight due to open files in CL..")
889
- move_open_files_to_default(change_obj.change)
891
+ change_obj = sorted_change_obj_list[int(chosen_index)]
892
+
893
+ verify_changelist(change_obj, sorted_change_obj_list)
894
+ if get_opened_file_list(change_obj.change):
895
+ shelve_changelist = attempt_shelve_changelist(change_obj.change)
896
+ if use_server_submit and commit_on_success:
897
+ secho(f"Reverting files from CL {change_obj.change} to allow for submit on the server..")
898
+ revert_file_in_cl("//...", change_obj.change)
899
+ else:
900
+ if change_obj.is_shelved:
901
+ shelve_changelist = change_obj.change
890
902
  else:
891
- if change_obj.is_shelved:
892
- shelve_changelist = change_obj.change
893
- else:
894
- abort(f"No opened files or shelve to work with in changelist '{change_obj.change}'...")
895
-
896
- build_id = get_shelve_preflight_build_id(
897
- shelve_changelist, type=type, stream=get_client_stream(change_obj.client), submit_on_server=use_server_submit
898
- )
903
+ abort(f"No opened files or shelve to work with in changelist '{change_obj.change}'...")
904
+
905
+ use_content_build = shelf_is_content_only(changelist)
906
+ build_id = get_shelve_preflight_build_id(
907
+ shelve_changelist, type=type, stream=get_client_stream(change_obj.client), print_output=verbose, submit_on_server=(use_server_submit and commit_on_success), content_only_build=use_content_build
908
+ )
909
+
910
+ if use_server_submit:
911
+ secho("\nBuild is requested, it is safe to close this window at any time!\n")
899
912
 
900
913
  wait_on_teamcity_build(build_id, shelve_changelist, use_server_submit)
901
914
 
@@ -906,4 +919,5 @@ def main(
906
919
  secho("Preflight finished successfully.", fg="green", bold=True)
907
920
  if commit_on_success and not use_server_submit:
908
921
  commit(shelve_changelist)
922
+
909
923
  return
@@ -1 +0,0 @@
1
- 0.9.24
File without changes
File without changes
File without changes