Skip to content

Commit

Permalink
fix: more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlancehu committed Feb 3, 2023
1 parent 65071cf commit 8dc1ca8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
7 changes: 6 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
"justMyCode": true,
"args": [
"-F",
"${file}"]
"${file}",
"--upx-dir",
"upx",
"-i",
"icon.ico"
]
}
]
}
32 changes: 21 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,35 @@
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.lighthouse.v20200324 import lighthouse_client, models


# Init
needupdate = False
checkpassing = True


# Get config
try:
configpath
except NameError:
configpath = 'config.json'
try:
open(configpath, 'r')
json.load(open(configpath, 'r', encoding='utf-8'))
except FileNotFoundError:
print('Config file not found')
exit()
except FileExistsError:
print('Config file exists error')
exit()
with open(configpath, 'r') as f:
except json.decoder.JSONDecodeError:
print('Incorrect configuration file format')
exit()
except UnicodeDecodeError:
print('Incorrect configuration file, it should be a text file using utf-8 encoding')
exit()
except Exception as e:
print('Unknown error: ' + str(e))
exit()
with open(configpath, 'r', encoding='utf-8') as f:
config = json.load(f)
f.close()
# Get IP
Expand All @@ -46,24 +57,23 @@
print('SecretKey not found')
checkpassing = False
# Check InstanceID
elif 'InstanceId' not in config:
if 'InstanceId' not in config:
print('InstanceID not found')
checkpassing = False
# Check Region
elif 'InstanceRegion' not in config:
if 'InstanceRegion' not in config:
print('InstanceRegion not found')
checkpassing = False
elif 'Rules' not in config:
if 'Rules' not in config:
print('Rules not found')
checkpassing = False
else:
InstanceId = config['InstanceId']
InstanceRegion = config['InstanceRegion']
cred = credential.Credential(config['SecretId'], config['SecretKey'])
rules = json.dumps(config['Rules'])
print('Config load successfully')
if checkpassing == False:
exit()
InstanceId = config['InstanceId']
InstanceRegion = config['InstanceRegion']
cred = credential.Credential(config['SecretId'], config['SecretKey'])
rules = json.dumps(config['Rules'])
print('Config load successfully')


# Get Firewall Rules
Expand Down

0 comments on commit 8dc1ca8

Please sign in to comment.