fix sync error

This commit is contained in:
Zenaku 2026-06-10 07:21:02 -05:00
parent b843160304
commit abe350294d

View file

@ -1,4 +1,4 @@
from core.Errors import MissingSubscriptionError, InvalidSubscriptionError, ConnectionUnprotectedError, EndpointVerificationError, ProfileStateConflictError, PaymentRequiredError from core.Errors import MissingSubscriptionError, InvalidSubscriptionError, ConnectionUnprotectedError, EndpointVerificationError, ProfileStateConflictError, PaymentRequiredError, UnknownConnectionTypeError
from core.controllers.ApplicationVersionController import ApplicationVersionController from core.controllers.ApplicationVersionController import ApplicationVersionController
from core.controllers.InvoiceController import InvoiceController from core.controllers.InvoiceController import InvoiceController
from core.controllers.LocationController import LocationController from core.controllers.LocationController import LocationController
@ -184,6 +184,10 @@ def handle(arguments, main_parser):
except SingboxNotInstalledException: except SingboxNotInstalledException:
main_parser.error('sing-box is not installed. Please run the installation script first.') main_parser.error('sing-box is not installed. Please run the installation script first.')
except UnknownConnectionTypeError:
print('No connection method configured. Please run:\n')
print(' python -m cli set connection system')
print(' python -m cli sync\n')
except PaymentRequiredError: except PaymentRequiredError:
print('Payment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.') print('Payment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.')
except (InvalidSubscriptionError, MissingSubscriptionError) as exception: except (InvalidSubscriptionError, MissingSubscriptionError) as exception:
@ -218,25 +222,32 @@ def _handle_subscription_error(exception, profile, ignore, arguments, main_parse
subscription_plan = SubscriptionPlanController.get(profile.connection, 720) subscription_plan = SubscriptionPlanController.get(profile.connection, 720)
if subscription_plan is None: if subscription_plan is None:
raise RuntimeError('No compatible subscription plan was found. Please contact support.') if not SubscriptionPlanController.get_all():
print('\nData not synchronized. Please run the following commands and try again:\n')
print(' python -m cli set connection system')
print(' python -m cli sync\n')
else:
print('\nNo compatible subscription plan was found. Please contact support.\n')
return
potential_subscription = SubscriptionController.create(subscription_plan, profile, connection_observer=connection_observer) potential_subscription = SubscriptionController.create(subscription_plan, profile, connection_observer=connection_observer)
if potential_subscription is None: if potential_subscription is None:
raise RuntimeError('The subscription could not be created. Please try again later.') print('\nThe subscription could not be created. Please try again later.\n')
return
ProfileController.attach_subscription(profile, potential_subscription) ProfileController.attach_subscription(profile, potential_subscription)
if potential_subscription.operator_id is None: if potential_subscription.operator_id is None:
subscription = InvoiceController.handle_payment(potential_subscription.billing_code, invoice_observer=invoice_observer, connection_observer=connection_observer) subscription = InvoiceController.handle_payment(potential_subscription.billing_code, invoice_observer=invoice_observer, connection_observer=connection_observer)
if subscription is None: if subscription is None:
print('\nPayment processing is currently unavailable. Please try again later or contact support.') print('\nPayment processing is currently unavailable. Please try again later or contact support.\n')
return return
ProfileController.attach_subscription(profile, subscription) ProfileController.attach_subscription(profile, subscription)
try: try:
ProfileController.enable(profile, ignore=ignore, pristine=arguments.pristine, asynchronous=True, profile_observer=profile_observer, application_version_observer=application_version_observer, connection_observer=connection_observer) ProfileController.enable(profile, ignore=ignore, pristine=arguments.pristine, asynchronous=True, profile_observer=profile_observer, application_version_observer=application_version_observer, connection_observer=connection_observer)
except PaymentRequiredError: except PaymentRequiredError:
print('\nPayment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.') print('\nPayment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.\n')
return return
elif manage_subscription_input == '2': elif manage_subscription_input == '2':
@ -248,7 +259,7 @@ def _handle_subscription_error(exception, profile, ignore, arguments, main_parse
try: try:
ProfileController.enable(profile, ignore=ignore, pristine=arguments.pristine, asynchronous=True, profile_observer=profile_observer, application_version_observer=application_version_observer, connection_observer=connection_observer) ProfileController.enable(profile, ignore=ignore, pristine=arguments.pristine, asynchronous=True, profile_observer=profile_observer, application_version_observer=application_version_observer, connection_observer=connection_observer)
except PaymentRequiredError: except PaymentRequiredError:
print('\nPayment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.') print('\nPayment processing is currently unavailable. The subscription could not be activated.\nPlease try again later or contact support.\n')
return return
else: else:
print('\nThe billing code appears to be invalid.\n') print('\nThe billing code appears to be invalid.\n')