]> Repositories - rushbound.git/blob - addons/godot_super-wakatime/utils.gd
Design and import typeface
[rushbound.git] / addons / godot_super-wakatime / utils.gd
1 func plugin_print(msg) -> void:
2         """Print message from plugin"""
3         print("[Godot_Super-Wakatime]: %s" % msg)
4         
5 func plugin_print_err(err) -> void:
6         """Inform about error from plugin"""
7         push_error("[Godot_Super-Wakatime]: %s" % err)
8
9 func set_platform():
10         """Set currently used platform"""
11         var platform: String = "linux"
12         var architecture: String = "arm64"
13
14         if OS.has_feature("windows") or OS.has_feature("uwp"):
15                 platform = "windows"
16         elif OS.has_feature("linux"):
17                 platform = "linux"
18         elif OS.has_feature("macos"):
19                 platform = "darwin"
20         elif OS.has_feature("android"):
21                 platform = "android"
22         elif OS.has_feature("ios"):
23                 platform = "ios"
24         
25         if OS.has_feature("x86_64"):
26                 architecture = "amd64"
27         elif OS.has_feature("x86_32"):
28                 architecture = "amd32"
29         elif OS.has_feature("arm64"):
30                 architecture = "arm64"
31         elif OS.has_feature("arm32"):
32                 architecture = "arm32"
33
34         return [platform, architecture]
35
36 func get_waka_build(platform: String, architecture: String) -> String:
37         """Return wakatime build for current OS"""
38         return "wakatime-cli-%s-%s" % [platform, architecture]
39
40 func get_ouch_build(system_platform: String) -> String:
41         """Get build for ouch (compression and decompression tool)"""
42         var platform: String = "linux-musl"
43         if system_platform == "windows":
44                 platform = "pc-windows-msvc"
45         elif system_platform == "darwin":
46                 platform = "apple-darwin"
47
48         return "ouch-%s-%s" % ["x86_64", platform]
49         
50 func home_directory(platform: String, plugin_path: String) -> String:
51         """Get home directory from """
52         var home = null
53         for env in ["WAKATIME_HOME", "USERPROFILE", "HOME"]:
54                 home = OS.get_environment(env)
55                 if home:
56                         if platform == "windows":
57                                 home = home.replace("\\", '/')
58                         return home
59         return plugin_path
60         
61 func config_filepath(platform: String, plugin_path: String) -> String:
62         """Get path to wakatime configuration file"""
63         return "%s/.wakatime.cfg" % home_directory(platform, plugin_path)
64         
65 func wakatime_cli_exists(wakatime_cli) -> bool:
66         """Return if wakatime cli tool exists already"""
67         return FileAccess.file_exists(wakatime_cli)
68         
69 func wakatime_zip_exists(wakatime_zip: String) -> bool:
70         "Check if wakatime zip file exists"
71         return FileAccess.file_exists(wakatime_zip)