Skip to content

Commit 04191bc

Browse files
committed
double attempt
1 parent 6d286e2 commit 04191bc

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

.github/workflows/test-metatrader5-integration.yml

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,41 +77,53 @@ jobs:
7777
portable_path = os.environ.get('MT5_PORTABLE_PATH')
7878
mt5_path = os.path.join(portable_path, 'terminal64.exe')
7979
80-
# First attempt: using portable path
81-
result = mt5.initialize(
82-
path=mt5_path,
83-
login=0,
84-
password='',
85-
server='',
86-
timeout=60000
87-
)
80+
print('Starting MT5 initialization...')
8881
89-
print(f'Result with portable path: {result}, Error code: {mt5.last_error()}')
82+
# Set environment variable directly in Python
83+
os.environ['MT5_HEADLESS'] = '1'
9084
91-
# If first attempt fails, try alternative approach
85+
# Initialize with minimal parameters
86+
result = mt5.initialize()
87+
88+
print(f'Initial result: {result}, Error code: {mt5.last_error()}')
89+
90+
# If the initial attempt fails, try additional methods
9291
if not result:
93-
print('First attempt failed. Trying default initialization...')
94-
mt5.shutdown()
95-
time.sleep(2)
96-
97-
# Second attempt: default init
98-
result = mt5.initialize(timeout=60000)
99-
print(f'Result with default init: {result}, Error code: {mt5.last_error()}')
100-
101-
# Third attempt: standard path
92+
print('Initial attempt failed. Trying with portable path...')
93+
result = mt5.initialize(
94+
path=mt5_path,
95+
login=0,
96+
password='',
97+
server='',
98+
timeout=60000
99+
)
100+
101+
print(f'Result with portable path: {result}, Error code: {mt5.last_error()}')
102+
103+
# If first attempt fails, try alternative approach
102104
if not result:
103-
print('Second attempt failed. Trying with standard path...')
105+
print('First attempt failed. Trying default initialization...')
104106
mt5.shutdown()
105107
time.sleep(2)
106-
result = mt5.initialize(
107-
path='C:\\\\Program Files\\\\MetaTrader 5\\\\terminal64.exe',
108-
timeout=60000
109-
)
110-
print(f'Result with standard path: {result}, Error code: {mt5.last_error()}')
111108
109+
# Second attempt: default init
110+
result = mt5.initialize(timeout=60000)
111+
print(f'Result with default init: {result}, Error code: {mt5.last_error()}')
112+
113+
# Third attempt: standard path
112114
if not result:
113-
print('All initialization attempts failed')
114-
sys.exit(1)
115+
print('Second attempt failed. Trying with standard path...')
116+
mt5.shutdown()
117+
time.sleep(2)
118+
result = mt5.initialize(
119+
path='C:\\\\Program Files\\\\MetaTrader 5\\\\terminal64.exe',
120+
timeout=60000
121+
)
122+
print(f'Result with standard path: {result}, Error code: {mt5.last_error()}')
123+
124+
if not result:
125+
print('All initialization attempts failed')
126+
sys.exit(1)
115127
116128
print('MT5 initialized successfully')
117129
account_info = mt5.account_info()

0 commit comments

Comments
 (0)