path_utils.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import platform, sys, os
  2. def getSystemPath():
  3. '''
  4. 获取系统目录
  5. '''
  6. if platform.system() == 'Windows':
  7. return 'win'
  8. elif platform.system() == 'Darwin':
  9. return 'macos'
  10. else:
  11. return 'linux'
  12. def get_current_path():
  13. """
  14. 当前目录
  15. """
  16. return sys.path[0]
  17. def getToolWithSystem(tool):
  18. '''
  19. 获取系统相关工具
  20. '''
  21. system = getSystemPath()
  22. suffix = getSystemSuffix()
  23. return os.path.join(getFullToolPath(system), tool + suffix)
  24. def getFullToolPath(name):
  25. '''
  26. 获取工具的目录
  27. '''
  28. return get_full_path('tools', name)
  29. def get_full_path(gen, *name):
  30. '''
  31. 主目录拼接对应路径
  32. '''
  33. path = os.path.join(get_current_path(), gen)
  34. for n in name:
  35. path = os.path.join(path, str(n))
  36. return path
  37. def getChannelPath(sdk):
  38. """
  39. 获取渠道的目录
  40. """
  41. return get_full_path('channel', sdk)
  42. def getSystemSuffix():
  43. """
  44. 系统工具后缀
  45. """
  46. if platform.system() == 'Windows':
  47. return '.exe'
  48. else:
  49. return ''
  50. def get_aapt_path():
  51. """
  52. 获取aapt
  53. """
  54. return getToolWithSystem('aapt')
  55. def get_aapt2_path():
  56. """
  57. 获取aapt2
  58. """
  59. return getToolWithSystem('aapt2')
  60. def get_android_compile_tool_path():
  61. """
  62. 获取android.jar
  63. """
  64. return getFullToolPath('android.jar')
  65. def get_dx_path():
  66. """
  67. 获取dx.jar
  68. """
  69. return getFullToolPath('dx.jar')
  70. def get_d8_path():
  71. """
  72. 获取d8.jar
  73. """
  74. return getFullToolPath('d8.jar')
  75. def get_zipalign_path():
  76. """
  77. 获取zipalign
  78. """
  79. return getToolWithSystem('zipalign')
  80. def get_multidex_path():
  81. """
  82. 获取multidex.jar
  83. """
  84. return getFullToolPath('android-support-multidex.jar')
  85. def get_apktool_path():
  86. """
  87. 获取apktool.jar
  88. """
  89. return getToolWithSystem('apktool_2.6.0.jar')
  90. def get_baksmali_path():
  91. """
  92. 获取baksmali.jar
  93. """
  94. return getFullToolPath('baksmali-2.3.jar')
  95. def get_keytool_path():
  96. return connsta
  97. def get_apksigner_path():
  98. '''
  99. 获取apksigner.jar
  100. '''
  101. return getFullToolPath('apksigner.jar')
  102. def get_sdk_log_path(gcp_code):
  103. return get_full_path("log", gcp_code)
  104. def get_sdk_channel_path(channel):
  105. return get_full_path("channel", channel)