fix: 添加调试日志
This commit is contained in:
parent
47899ba5f5
commit
0485f2d75d
|
|
@ -23,17 +23,25 @@ print(f"Arguments: {sys.argv}")
|
|||
print("=====================================")
|
||||
sys.stdout.flush()
|
||||
|
||||
print("Attempting to import config and utils...")
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
from config import settings
|
||||
from utils import setup_logger
|
||||
except ImportError:
|
||||
print("Successfully imported config and utils")
|
||||
except ImportError as e:
|
||||
print(f"Failed to import config/utils: {e}")
|
||||
# Fallback for when running as script
|
||||
import logging
|
||||
settings = type('Settings', (), {'LOG_LEVEL': 'INFO'})()
|
||||
def setup_logger(name):
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
return logging.getLogger(name)
|
||||
print("Using fallback config and logger")
|
||||
sys.stdout.flush()
|
||||
|
||||
print("Attempting to import AI video modules...")
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
from .cloud_storage import CloudStorage
|
||||
from .api_client import APIClient
|
||||
|
|
@ -43,9 +51,16 @@ except ImportError as e:
|
|||
print(f"Import error with relative imports: {e}")
|
||||
try:
|
||||
# Fallback for when running as script
|
||||
print("Trying direct imports...")
|
||||
sys.stdout.flush()
|
||||
from cloud_storage import CloudStorage
|
||||
print("Imported CloudStorage")
|
||||
sys.stdout.flush()
|
||||
from api_client import APIClient
|
||||
print("Imported APIClient")
|
||||
sys.stdout.flush()
|
||||
from jsonrpc import create_response_handler, create_progress_reporter, JSONRPCError
|
||||
print("Imported JSON-RPC modules")
|
||||
print("Successfully imported modules with direct imports")
|
||||
except ImportError as e2:
|
||||
print(f"CRITICAL ERROR: Failed to import required modules: {e2}")
|
||||
|
|
@ -54,28 +69,41 @@ except ImportError as e:
|
|||
print("Module directory contents:", os.listdir(os.path.dirname(__file__)))
|
||||
sys.stdout.flush()
|
||||
sys.exit(1)
|
||||
sys.stdout.flush()
|
||||
|
||||
logger = setup_logger(__name__)
|
||||
|
||||
class VideoGenerator:
|
||||
"""AI video generator for converting images to videos."""
|
||||
|
||||
def __init__(self,
|
||||
def __init__(self,
|
||||
api_key: str = None,
|
||||
cos_config: Dict[str, str] = None):
|
||||
"""
|
||||
Initialize video generator.
|
||||
|
||||
|
||||
Args:
|
||||
api_key: API key for video generation service
|
||||
cos_config: Cloud storage configuration
|
||||
"""
|
||||
print("Initializing VideoGenerator...")
|
||||
sys.stdout.flush()
|
||||
|
||||
print("Creating APIClient...")
|
||||
sys.stdout.flush()
|
||||
self.api_client = APIClient(api_key=api_key)
|
||||
|
||||
print("APIClient created successfully")
|
||||
sys.stdout.flush()
|
||||
|
||||
print("Creating CloudStorage...")
|
||||
sys.stdout.flush()
|
||||
if cos_config:
|
||||
self.cloud_storage = CloudStorage(**cos_config)
|
||||
else:
|
||||
self.cloud_storage = CloudStorage()
|
||||
print("CloudStorage created successfully")
|
||||
print("VideoGenerator initialization complete")
|
||||
sys.stdout.flush()
|
||||
|
||||
def generate_video_from_image(self,
|
||||
image_path: str,
|
||||
|
|
@ -397,8 +425,18 @@ def main():
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
print("Parsed arguments successfully")
|
||||
print(f"Action: {args.action}")
|
||||
print(f"Image: {args.image}")
|
||||
print(f"Output: {args.output}")
|
||||
sys.stdout.flush()
|
||||
|
||||
try:
|
||||
print("Creating VideoGenerator instance...")
|
||||
sys.stdout.flush()
|
||||
generator = VideoGenerator()
|
||||
print("VideoGenerator created successfully")
|
||||
sys.stdout.flush()
|
||||
|
||||
def progress_callback(message):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue