Skip to content

Commit 882c521

Browse files
update
1 parent 930af6b commit 882c521

File tree

2 files changed

+70
-59
lines changed

2 files changed

+70
-59
lines changed

eosfactory/core/config.py

Lines changed: 70 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -86,35 +86,39 @@ def get_app_data_dir():
8686
return app_data_dir
8787

8888
raise errors.Error('''
89-
Cannot determine the directory of application data. Tried:
90-
'{}',
91-
'{}',
92-
'{}'.
93-
The chosen path is
94-
'{}',
95-
but it does not exist, seemingly.
89+
Cannot determine the directory of application data. Tried:
90+
{}
91+
{}
92+
{}
93+
The path '__file__' is
94+
{}
95+
The chosen path is
96+
{}
97+
but it does not exist, seemingly.
9698
'''.format(
9799
APP_DATA_DIR_SUDO[0], APP_DATA_DIR_USER[0], eosf_dir(),
100+
__file__,
98101
app_data_dir),
99102
translate=False)
100103

101104

102105
def is_linked_package():
103106
is_linked = os.path.exists(os.path.join(eosf_dir(), CONFIG_DIR))
104-
is_copied = not is_linked and get_app_data_dir()
105-
if (not is_linked) and (not is_copied):
107+
is_installed_package = not is_linked and get_app_data_dir()
108+
109+
if (not is_linked) and (not is_installed_package):
106110
raise errors.Error('''
107-
Cannot determine the configuration directory.
108-
{}
109-
{}
110-
{}
111+
Cannot determine the configuration directory.
112+
{}
113+
{}
114+
{}
111115
'''.format(
112116
os.path.join(eosf_dir(), CONFIG_DIR),
113117
os.path.join(APP_DATA_DIR_USER[0], CONFIG_DIR),
114118
os.path.join(APP_DATA_DIR_SUDO[0], CONFIG_DIR)
115119
), translate=False)
116120

117-
if is_linked and is_copied:
121+
if is_linked and is_installed_package:
118122
is_linked = True
119123

120124
return is_linked
@@ -154,11 +158,11 @@ def set(contract_workspace_dir):
154158
contract_workspace_dir = os.path.join(APP_CWD_DIR, CONTRACTS_DIR)
155159

156160
new_dir = tilde(input(utils.heredoc('''
157-
Where do you prefer to keep your smart-contract projects?
158-
The current location of the is:
159-
'{}'
160-
Otherwise, input another existing directory path, or nothing to
161-
keep the current one:
161+
Where do you prefer to keep your smart-contract projects?
162+
The current location of the is:
163+
{}
164+
Otherwise, input another existing directory path, or nothing to
165+
keep the current one:
162166
'''.format(
163167
colored(contract_workspace_dir, current_path_color)
164168
)
@@ -172,9 +176,9 @@ def set(contract_workspace_dir):
172176
break
173177
else:
174178
print("\n" + utils.heredoc('''
175-
The path you entered:
176-
{}
177-
doesn't seem to exist!
179+
The path you entered:
180+
{}
181+
doesn't seem to exist!
178182
''').format(colored(new_dir, error_path_color)) + "\n")
179183

180184

@@ -262,9 +266,9 @@ def contract_workspace_dir(dont_set_workspace=False):
262266
return path
263267
else:
264268
raise errors.Error('''
265-
The path
266-
'{}',
267-
set as the contract workspace directory, does not exist.
269+
The path
270+
'{}',
271+
set as the contract workspace directory, does not exist.
268272
'''.format(path), translate=False)
269273
else:
270274
if is_linked_package():
@@ -278,9 +282,9 @@ def contract_workspace_dir(dont_set_workspace=False):
278282
return path
279283
else:
280284
raise errors.Error('''
281-
The path
282-
'{}'
283-
resolved as the contract workspace directory directory does not exist.
285+
The path
286+
'{}'
287+
resolved as the contract workspace directory directory does not exist.
284288
'''.format(workspace_dir, translate=False)
285289
)
286290
return path
@@ -303,18 +307,25 @@ def abi_file(contract_dir_hint):
303307
def eosf_dir():
304308
'''The absolute directory of the EOSFactory installation.
305309
'''
306-
path = os.path.realpath(os.path.join(
310+
try:
311+
path = os.path.realpath(os.path.join(
307312
os.path.realpath(__file__), FROM_HERE_TO_EOSF_DIR))
313+
except Exception as e:
314+
raise errors.Error('''
315+
Impossible error: __file__ path cannot be determined. The message is
316+
{}
317+
'''.format(str(e)))
318+
308319
if os.path.exists(path):
309320
return path
310321

311322
raise errors.Error('''
312-
Cannot determine the root directory of EOSFactory.
313-
The path to the file 'config.py' is
314-
'{}'.
315-
The expected path to the installation, which is
316-
'{}',
317-
is reported as non-existent.
323+
Cannot determine the root directory of EOSFactory.
324+
The path to the file 'config.py' is
325+
'{}'.
326+
The expected installation path, which is
327+
'{}',
328+
is reported as non-existent.
318329
'''.format(__file__, path), translate=False)
319330

320331

@@ -380,9 +391,9 @@ def genesis_json():
380391
path = os.path.join(config_dir(), "genesis.json")
381392
if not os.path.exists(path):
382393
raise errors.Error('''
383-
Cannot find any path for '{}'.
384-
Tried:
385-
{}
394+
Cannot find any path for '{}'.
395+
Tried:
396+
{}
386397
'''.format(genesis_json_[0], genesis_json_[1]), translate=False)
387398

388399
return path
@@ -621,9 +632,9 @@ def keosd_wallet_dir(raise_error=True):
621632
if not path:
622633
if raise_error:
623634
raise errors.Error('''
624-
Cannot find any path for '{}'.
625-
Tried:
626-
{}
635+
Cannot find any path for '{}'.
636+
Tried:
637+
{}
627638
'''.format(keosd_wallet_dir_[0], keosd_wallet_dir_[1]),
628639
translate=False)
629640

@@ -777,9 +788,9 @@ def first_valid_which(config_list, find_file=None, raise_error=True):
777788
if raise_error:
778789
config_values(config_list)
779790
raise errors.Error('''
780-
Cannot find any path for '{}'.
781-
Tried:
782-
{}
791+
Cannot find any path for '{}'.
792+
Tried:
793+
{}
783794
'''.format(config_list[0], config_list[1]), translate=False)
784795
else:
785796
return None
@@ -831,9 +842,9 @@ def first_valid_path(config_list, find_file=None, raise_error=True):
831842

832843
if raise_error:
833844
raise errors.Error('''
834-
Cannot find any path for '{}'.
835-
Tried:
836-
{}
845+
Cannot find any path for '{}'.
846+
Tried:
847+
{}
837848
'''.format(config_list[0], config_list[1]), translate=False)
838849
else:
839850
return None
@@ -880,9 +891,9 @@ def contract_dir(contract_dir_hint):
880891
return os.path.realpath(contract_dir_)
881892

882893
raise errors.Error('''
883-
Cannot determine the contract directory.
884-
Tried:
885-
{}
894+
Cannot determine the contract directory.
895+
Tried:
896+
{}
886897
'''.format(trace), translate=False)
887898

888899

@@ -925,9 +936,9 @@ def contract_source_files(contract_dir_hint):
925936
return (source_dir, srcs)
926937

927938
raise errors.Error('''
928-
Cannot find any contract source directory.
929-
Tried:
930-
{}
939+
Cannot find any contract source directory.
940+
Tried:
941+
{}
931942
'''.format(trace), translate=False)
932943

933944

@@ -990,11 +1001,11 @@ def contract_file(contract_dir_hint, contract_file_hint):
9901001
return os.path.join(build_dir, file)
9911002

9921003
raise errors.Error('''
993-
Cannot determine the contract file basing on hints:
994-
contract dir hint: {}
995-
contract file hint: {}
996-
Tried:
997-
{}
1004+
Cannot determine the contract file basing on hints:
1005+
contract dir hint: {}
1006+
contract file hint: {}
1007+
Tried:
1008+
{}
9981009
'''.format(contract_dir_hint, contract_file_hint, trace), translate=False)
9991010

10001011

@@ -1215,7 +1226,7 @@ def config():
12151226
Python version {}
12161227
'''.format(VERSION, EOSIO_VERSION, EOSIO_CDT_VERSION, PYTHON_VERSION)
12171228
)
1218-
1229+
import pdb; pdb.set_trace()
12191230
if is_linked_package():
12201231
print(
12211232
'''
File renamed without changes.

0 commit comments

Comments
 (0)