forked from TeamOctoTagger/OctoTagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
executable file
·71 lines (58 loc) · 1.65 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import stat
from sys import platform
def exec_setup():
os.system("python db/setup.py")
def write_desktop_file():
path = os.path.abspath(os.getcwd())
desktop_file_content = (
("[Desktop Entry]\n"
"Encoding=UTF-8\n"
"Version=1.0\n"
"Type=Application\n"
"Name=OctoTagger\n"
"Icon=%s\n"
"Path=%s\n"
"Exec=python src/octotagger.py\n"
"StartupNotify=false\n"
"StartupWMClass=Octotagger.py\n"
"OnlyShowIn=Unity") %
(os.path.join(path, "icons/logo.png"),
path)
)
desktop_file_path = os.path.expanduser(
"~/.local/share/applications/octotagger.desktop"
)
desktop_file = open(
desktop_file_path,
"w"
)
desktop_file.write(desktop_file_content)
os.chmod(desktop_file_path, os.stat(
desktop_file_path).st_mode | stat.S_IEXEC)
def create_shortcut_file():
run_script_path = os.path.join(os.getcwd(), "OctoTagger.command")
run_script = open(
run_script_path,
"w"
)
# TODO: Hide terminal window
run_script_content = (
'#!/bin/sh\n'
'cd %s\n'
'python ./src/octotagger.py' %
(os.getcwd())
)
run_script.write(run_script_content)
os.chmod(run_script_path, os.stat(
run_script_path).st_mode | stat.S_IEXEC)
shortcut_file = os.path.expanduser("~/Desktop/OctoTagger.command")
os.symlink(run_script_path, shortcut_file)
if platform == "darwin":
exec_setup()
create_shortcut_file()
elif platform.startswith("linux"):
exec_setup()
write_desktop_file()