Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:35:52+00:00 2026-06-11T15:35:52+00:00

I am trying to compare a file stored in a list to the same

  • 0

I am trying to compare a file stored in a list to the same file located on a server that may be W2K3 or W2K8. I am trying to use a single function to this but am stuck at this if statement. I am trying to figure out how to get the proper directory path into os.walk():

    if osVer == 'serverW2k3':
        continue
    elif osVer == 'serverW2k8':
        for folder, subfolders, files in os.walk():

I did have this working before but had repeating lines so I wanted to simplify the code.
Here is the full class:

class checkstatus:
    def __init__(self):
        print 'Checking Status...'
        chkbkpstats = csv.reader(file('c://temp//networkerservers.csv'))

        srvrs = []
        for row in chkbkpstats:
            srvrs.append({'Name' : row[0], 'Instance' : row[1]})

        for srvr in srvrs:
            srvrName = (srvr['Name'])
            srvrInst = (srvr['Instance'])
            w2k3Chk = r'\\%s\d$\DA$Utils\log\networker' % srvrName
            w2k8Chk = r'\\%s\c$\ProgramData\SQL\DA$Utils\log\networker' % srvrName

            try:
                c = wmi.WMI(srvr['Name'])

            except:
                print 'Error connecting to %s to check OS version' % srvrName

            else:
                osVer = c.Win32_OperatingSystem()[0].Caption
                if '2003' in osVer:
                    return 'serverW2k3'
                    #self.fileCheck(w2k3Chk, w2k8Chk, srvrInst, srvrName)

                elif '2008' in osVer:
                    return 'serverW2k8'
                    #self.fileCheck(w2k3Chk, w2k8Chk, srvrInst, srvrName)

    def fileCheck(self, w2k3Chk, w2k8Chk, srvrInst, srvrName, osVer):
        found = False
        if osVer == 'serverW2k3':
            continue
        elif osVer == 'serverW2k8':
            for folder, subfolders, files in os.walk():
                for sqlFile in files:
                    if sqlFile == srvrInst + ".log":
                        found = True
                        print 'The Backup For %s on %s Still Running' % (srvrInst, srvrName)
                    elif sqlFile == (srvrInst + ".ok"):
                        found = True
                        print 'The Backup For %s on %s Completed Successfully' % (srvrInst, srvrName)
                    elif sqlFile == (srvrInst + ".err"):
                        found = True
                        print 'The Backup For %s on %s Has Failed' % (srvrInst, srvrName)
                if not found:
                    print 'No file for %s found on %s' % (srvrInst, srvrName)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:35:53+00:00Added an answer on June 11, 2026 at 3:35 pm

    Your question is a bit unclear, and your sample code obviously isn’t your real code (you can’t call os.walk with no params), but I think I can guess what you’re after.

    First, change fileCheck like this:

    def fileCheck(self, path, srvrInst, srvrName):
        found = False
        for folder, subfolders, files in os.walk(path):
            ...
    

    Now, in __init__, do the last part like this:

    else:
        osVer = c.Win32_OperatingSystem()[0].Caption
        if '2003' in osVer:
            self.fileCheck(w2k3Chk, srvrInst, srvrName)
        else:
            self.fileCheck(w2k8Chk, srvrInst, srvrName)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare two strings. One stored in a file, the other retrieved
I am trying to compare a list of forbidden folders read from a file.
I am trying to compare two files. I will list the two file content:
I'm trying to make a class that uses the Levenshtein distance function to compare
I'm trying to compare my highscore that I saved in A file to compare
I'm trying to compare a couple of array values stored in a flat file
So, I'm trying to use ADO.NET to stream a file data stored in an
Trying to compare and print only members with Inactive status. The problem is that
I am trying to use md5 code to calculate checksums of file. Now the
I have some simple text file. I am trying to read that file contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.