<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def should_aggregate(self, req):
 """Check the environment variable and the given argument parameter to decide if aggregations needed. argument value is expected to be '0' or '1' """

        try:
            return self.app.config.get('ELASTICSEARCH_AUTO_AGGREGATIONS') or \
                   bool(req.args and int(req.args.get('aggregations')))
        except (AttributeError, TypeError):
            return False