Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes for Python 3. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions sql-backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@
import sys
import subprocess
from datetime import datetime
from optparse import OptionParser
from argparse import ArgumentParser

# Configuration has to be stored in a global variable as it has to be
# accessible to all functions
config = None

def main():
parser = OptionParser()
parser.add_option('-c', '--config', dest='config',
help='path to configuration', metavar='FILE')
parser.add_option('-v', '--verbose',
action='store_true', dest='verbose', default=False,
help='print status messages to stdout')
parser.add_option('-u', '--user', dest='user',
help='user owning database', metavar='USER')
parser.add_option('-d', '--database', dest='database',
help='database to back up', metavar='DB')
parser.add_option('--daily', dest='type',
action='store_const', const='daily')
parser.add_option('--local', dest='type',
action='store_const', const='')
parser = ArgumentParser(description='Back up SQL.')
parser.add_argument('-c', '--config', dest='config',
help='path to configuration', metavar='FILE')
parser.add_argument('-v', '--verbose',
action='store_true', dest='verbose', default=False,
help='print status messages to stdout')
parser.add_argument('-u', '--user', dest='user',
help='user owning database', metavar='USER')
parser.add_argument('-d', '--database', dest='database',
help='database to back up', metavar='DB')
parser.add_argument('--daily', dest='type',
action='store_const', const='daily')
parser.add_argument('--local', dest='type',
action='store_const', const='')
parser.set_defaults(type='daily')
(options, args) = parser.parse_args()
options = parser.parse_args()

# Uncomment this to make -v actually work
logger.setLevel(logging.INFO if options.verbose else
Expand Down Expand Up @@ -157,7 +157,7 @@ def convert(letter):
return letter if letter in string.ascii_lowercase else 'other'
first = convert(inp[0])
second = convert(inp[1])
if first is 'other':
if first == 'other':
return first
return '%s/%s' % (first, second)

Expand Down