Skip to content

Commit feae438

Browse files
committed
read config.ini after package
1 parent cd43171 commit feae438

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

MarkdownPicPicker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
ImageFile.LOAD_TRUNCATED_IMAGES = True
1919

20-
__version__ = '0.2.1'
20+
__version__ = '0.2.2'
2121
__author__ = 'kingname'
2222

2323

@@ -57,11 +57,15 @@ def init_environment(self):
5757
os.makedirs(self.picture_folder)
5858

5959
def read_config(self):
60+
if getattr(sys, 'frozen', None):
61+
config_path = os.path.join(os.path.dirname(sys.executable), self.CONFIG_PATH)
62+
else:
63+
config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), self.CONFIG_PATH)
6064
configs = ConfigParser()
61-
if not os.path.exists(self.CONFIG_PATH):
65+
if not os.path.exists(config_path):
6266
print('can not find the config.ini, exit')
6367
exit()
64-
configs.read(self.CONFIG_PATH)
68+
configs.read(config_path)
6569
self.method = configs['basic'].get('run_method', '')
6670
self.picture_folder = configs['basic'].get('picture_folder', '')
6771
self.picture_suffix = configs['basic'].get('picture_suffix', '')

uploader/QiniuUploader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ def upload(self, picture_path, picture_name):
1515
info = put_file(token, picture_name, picture_path)
1616
print(info)
1717

18-
def write_markdown_picture_url(self, picture_name):
19-
markdown_picture_url = '![]({})'.format(self.url.format(picture_name))
18+
def write_markdown_picture_url(self, picture_name, link_only=False):
19+
if link_only:
20+
markdown_picture_url = self.url.format(picture_name)
21+
else:
22+
markdown_picture_url = '![]({})'.format(self.url.format(picture_name))
2023
command = 'echo {} | clip'.format(markdown_picture_url)
2124
os.system(command)

0 commit comments

Comments
 (0)