-
Notifications
You must be signed in to change notification settings - Fork 6
/
util.py
56 lines (49 loc) · 1.8 KB
/
util.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
# encoding:utf-8
import os
from consts import *
import workflow
APPLE_SCRIPT_DEFAULT_PROFILE = """
tell application "Microsoft Outlook"
set theAlias to current identity folder as alias
tell application "Finder"
return name of theAlias
end tell
end tell
"""
class Util(object):
@staticmethod
def isAlfredV2(wf):
return wf.alfred_env['version'][0] == 2
@staticmethod
def configureDefaultProfile(wf):
confFolder = workflow.util.run_applescript(APPLE_SCRIPT_DEFAULT_PROFILE)
confFolder = confFolder.strip()
# homePath = os.environ['HOME']
#
# defaultProfilePath = homePath + OUTLOOK_DATA_PARENT + OUTLOOK_DEFAULT_PROFILE
# confFolder = OUTLOOK_DEFAULT_PROFILE
#
# if not os.path.isdir(defaultProfilePath):
# # list all folders
# parent = homePath + OUTLOOK_DATA_PARENT
# profileFolders = os.listdir(parent)
#
# largestProfileSize = 0
# largestProfile = None
# for profile in profileFolders:
# if not profile.startswith('.'):
# if Util.validateProfile(parent + profile + OUTLOOK_DATA_FOLDER):
# size = os.path.getsize(parent + profile + OUTLOOK_DATA_FOLDER + OUTLOOK_SQLITE_FILE)
# if size > largestProfileSize:
# largestProfile = profile
#
# confFolder = largestProfile
#
# if confFolder:
# wf.logger.info("finally, we set profile to " + str(confFolder) + " as default profile conf!")
# else:
# wf.logger.info("no profile found")
wf.store_data(KEY_PROFILE, confFolder)
@staticmethod
def validateProfile(path):
return os.path.isfile(path + OUTLOOK_SQLITE_FILE)