@login
    @command(index=int)
    def do_status(self, index=1):
        """
        Usage: status <index>
        """
        docs = list(self.cache._for_adf('archives').iteritems())
        docs = sorted(docs, key=compose(creation, operator.itemgetter(1)))
        uploads = self.cache._get_uploads()
        if index <= 0 or len(docs) < index:
            print "No such archive"
        else:
            fname = docs[index-1][0]
            upload = docs[index-1][1]
            if fname in uploads:
                upload['links'].upload = uploads[fname]['uri']
            if 'signature' in upload:
                print "status: complete"
            elif 'links' in upload and upload['links'].upload:
                try:
                    url = upload['links'].upload
                    status = self.session.upload_status(url)
                    if status['status'] == "completed":
                        print "status: complete"
                        cert, f = self.cache.save_cert(
                            self.cache.upload_complete(fname, status))
                        if f:
                            print "Certificate", cert, "saved:", f
                        else:
                            print "Certificate", cert, "already exists.\n"
                        for i in range(3):
                            try:
                                UploadState.reset(fname)
                                break
                            except OSError as e:
                                if i < 3 and e.errno == errno.EACCES:
                                    continue
                                else:
                                    raise e
                        print " ".join(("Use lacli certificate list",
                                        "to see your certificates, or",
                                        "lacli certificate --help for",
                                        "more options"))
                    else:
                        print "upload not complete, status:", status['status']
                except Exception as e:
                    getLogger().debug("exception while checking status",
                                      exc_info=True)
                    print "error: " + str(e)
            else:
                print "status: local"
dataset/ETHPy150Open longaccess/longaccess-client/lacli/command.py/LaArchiveCommand.do_status/original