def UPSPackage(user, psswd): print(user) print(psswd) try: session = upsmychoice.get_session(user, psswd) #print(session.status_code) except: df3 = pd.DataFrame() print("invalid credentials") return df3, "skip" packages = upsmychoice.get_packages(session) filename = "UPS_" + user + "_" + psswd + ".csv" df1 = pd.DataFrame(packages) #df1 = df1[df1["status"] != "Delivered"] df1.drop(["estimated_delivery_timeframe"], axis=1, inplace=True) df1.drop(["delivery_date"], axis=1, inplace=True) df1.drop(["from"], axis=1, inplace=True) df1.drop(["from_location"], axis=1, inplace=True) ups = [] for i in range(len(df1)): ups.append("UPS") dd = pd.DataFrame({'carrier': ups}) df1 = pd.concat([dd, df1], axis=1) print(df1) return df1, "valid"
def _update(self): """Update device state.""" import upsmychoice status_counts = defaultdict(int) for package in upsmychoice.get_packages(self._session): status = slugify(package['status']) skip = status == STATUS_DELIVERED and \ parse_date(package['delivery_date']) < now().date() if skip: continue status_counts[status] += 1 self._attributes = {ATTR_ATTRIBUTION: upsmychoice.ATTRIBUTION} self._attributes.update(status_counts) self._state = sum(status_counts.values())
def _update(self): """Update device state.""" import upsmychoice status_counts = defaultdict(int) for package in upsmychoice.get_packages(self._session): status = slugify(package['status']) skip = status == STATUS_DELIVERED and \ parse_date(package['delivery_date']) < now().date() if skip: continue status_counts[status] += 1 self._attributes = { ATTR_ATTRIBUTION: upsmychoice.ATTRIBUTION } self._attributes.update(status_counts) self._state = sum(status_counts.values())
def _update(self): """Update device state.""" import upsmychoice status_counts = defaultdict(int) try: for package in upsmychoice.get_packages(self._session): status = slugify(package['status']) skip = status == STATUS_DELIVERED and \ parse_date(package['delivery_date']) < now().date() if skip: continue status_counts[status] += 1 except upsmychoice.UPSError: _LOGGER.error('Could not connect to UPS My Choice account') self._attributes = {ATTR_ATTRIBUTION: upsmychoice.ATTRIBUTION} self._attributes.update(status_counts) self._state = sum(status_counts.values())
def _update(self): """Update device state.""" import upsmychoice status_counts = defaultdict(int) try: for package in upsmychoice.get_packages(self._session): status = slugify(package['status']) skip = status == STATUS_DELIVERED and \ parse_date(package['delivery_date']) < now().date() if skip: continue status_counts[status] += 1 except upsmychoice.UPSError: _LOGGER.error('Could not connect to UPS My Choice account') self._attributes = { ATTR_ATTRIBUTION: upsmychoice.ATTRIBUTION } self._attributes.update(status_counts) self._state = sum(status_counts.values())