Overview
The project uses ZeroC Ice middleware to enable remote procedure calls between the backend server and clients. The ICE stubs are Python files automatically generated from theConversor.ice interface definition file.
You only need to regenerate stubs when you modify the
backend/Conversor.ice file. For normal development work, the existing stubs work without changes.Understanding ICE Stubs
The stubs are located in theConversor/ directory and include:
ConversorUnidades.py- Main interface implementationUnidadInvalidaException.py- Exception handlingConversorUnidades_forward.py- Forward declarations__init__.py- Package initialization
backend/Conversor.ice, which defines:
When to Regenerate Stubs
Regenerate the ICE stubs whenever you:Add New Methods
Adding new conversion methods or utility functions to the interface
Modify Parameters
Changing parameter types or adding new parameters to existing methods
Add Exceptions
Defining new exception types for error handling
Change Return Types
Modifying the return type of any method
Regenerating Stubs
Activate your virtual environment
Make sure your virtual environment is active before running the slice compiler.
- macOS/Linux
- Windows PowerShell
- Windows CMD
Run the slice2py compiler
From the project root directory, run:This command reads
backend/Conversor.ice and regenerates all Python stub files in the Conversor/ directory.Verify the generated files
Check that the You should see:
Conversor/ directory contains the updated stub files:ConversorUnidades.py(main interface)UnidadInvalidaException.py(exception class)ConversorUnidades_forward.py(forward declarations)__init__.py(package init)
Example: Adding a New Method
Let’s say you want to add volume conversion. Here’s the workflow:Troubleshooting
slice2py command not found
slice2py command not found
The If still not found, verify your virtual environment is activated:
slice2py command comes from the zeroc-ice package. Make sure it’s installed:Import errors after regenerating
Import errors after regenerating
If you see import errors after regenerating stubs:
- Restart your Python processes (server.py, web_server.py)
- Clear Python cache:
find . -type d -name __pycache__ -exec rm -rf {} + - Verify the
Conversor/__init__.pyfile exists
Syntax errors in Conversor.ice
Syntax errors in Conversor.ice
If slice2py reports errors:
- Check for missing semicolons
- Verify all braces are balanced
- Ensure all methods have return types
- Confirm exception declarations are properly formatted
Related Resources
ZeroC Ice Documentation
Official Ice documentation for Python
Slice Language Reference
Complete Slice language specification