This code will set photoshop to operate in pixels, then set it back to the previously used unit system again, allowing you to support the case where the units are not pixels:

```python
import photoshop

# set unit system to pixels, store previous mode
originalRulerUnits = photoshop.app.preferences.rulerUnits
pixels = photoshop.StaticObject('com.adobe.photoshop.Units', 'PIXELS')
photoshop.app.preferences.rulerUnits = pixels        

# execute code here which assume pixel units

# set units back to original
photoshop.app.preferences.rulerUnits = originalRulerUnits
```