示例#1
0
文件: __init__.py 项目: nstinus/pitz
def pitz_add_status():

    p = setup_options()
    p.add_option('-t', '--title', help='Status title')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    s = Status(
        proj,
        title=options.title or raw_input("Status title: ").strip(),
        description=clepy.edit_with_editor('# Status description goes here'),
    )

    proj.append(s)
    print("Added %s to the project." % s.summarized_view)
    proj.save_entities_to_yaml_files()
示例#2
0
文件: __init__.py 项目: nstinus/pitz
def pitz_estimate_task():

    # Start of code to set up project.
    p = setup_options()
    p.set_usage("%prog task [estimate]")

    options, args = p.parse_args()

    if not args:
        p.print_usage()
        return

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    # end of code to set up project.

    t = proj[args[0]]

    if len(args) == 2:
        est = proj[args[1]]

    else:
        est = Estimate.choose_from_already_instantiated()

    t['estimate'] = est

    # Save the project.
    proj.save_entities_to_yaml_files()
示例#3
0
    def test_fresh_pickle(self):
        """
        Verify we use the pickle when we can.
        """

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'pickle', p.loaded_from
示例#4
0
文件: __init__.py 项目: nstinus/pitz
def pitz_claim_task():

    p = setup_options()
    p.set_usage("%prog task")

    options, args = p.parse_args()

    if not args:
        p.print_usage()
        return

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    if not proj.me:
        print("Sorry, I don't know who you are.")
        print("Use pitz-me to add yourself to the project.")
        return

    t = proj[args[0]]
    t.assign(proj.me)
    proj.save_entities_to_yaml_files()
示例#5
0
文件: __init__.py 项目: nstinus/pitz
def pitz_destroy():

    p = setup_options()
    p.add_option('-t', '--title', help='Status title')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    e = proj[args[0]]

    if isinstance(e, Entity):

        e.self_destruct(proj)

    print("""%(frag)s: "%(title)s" is no longer part of the project."""
        % e)

    proj.save_entities_to_yaml_files()
示例#6
0
文件: __init__.py 项目: nstinus/pitz
def pitz_add_person():

    p = setup_options()
    p.add_option('-t', '--title', help='Person title')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    person = Person(
        proj,
        title=options.title or raw_input("Person title: ").strip(),
        description=clepy.edit_with_editor('# Person description goes here'),
    )

    proj.append(person)
    print("Added %s to the project." % person.summarized_view)
    proj.save_entities_to_yaml_files()

    if raw_input("Should I identify you as %(title)s? (y/N)" % person)\
    .strip().lower().startswith('y'):

        person.save_as_me_yaml()
        print("OK, I'll recognize you as %(title)s from now on.")
示例#7
0
文件: __init__.py 项目: nstinus/pitz
def pitz_attach_file():

    # Generic.
    p = setup_options()

    # Every script may have a slightly different usage.
    p.set_usage("%prog entity file-to-attach")

    # This is generic.
    options, args = p.parse_args()

    if options.version:
        print_version()
        return
    # End of generic stuff.

    # Every script may have different required args.
    if len(args) != 2:
        p.print_usage()
        return

    # Generic code to build the project.
    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    # Start of interesting stuff that is specific just for this script.
    e, filepath = proj[args[0]], args[1]

    e.save_attachment(filepath)

    # Save the project. (This could also be generic).
    proj.save_entities_to_yaml_files()
示例#8
0
文件: __init__.py 项目: nstinus/pitz
def pitz_add_milestone():

    p = setup_options()
    p.add_option('-t', '--title', help='Milestone title')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    pidfile = write_pidfile_or_die(pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    m = Milestone(
        proj,
        title=options.title or raw_input("Milestone title: ").strip(),
        description=clepy.edit_with_editor(
            '# Milestone description goes here'),
        reached=Milestone.choose_from_allowed_values('reached', False),
    )

    proj.append(m)
    print("Added %s to the project." % m.summarized_view)
    proj.save_entities_to_yaml_files()

    os.remove(pidfile)
示例#9
0
    def test_from_yaml_files(self):
        """
        Verify we can use the yaml files when no pickle exists.
        """

        os.unlink('/tmp/project.pickle')

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from
示例#10
0
文件: __init__.py 项目: nstinus/pitz
    def setup_proj(self, p, options, args):

        pitzdir = Project.find_pitzdir(options.pitzdir)
        pidfile = write_pidfile_or_die(pitzdir)
        proj = Project.from_pitzdir(pitzdir)

        log.debug("Loaded project from %s" % proj.loaded_from)

        proj.pidfile = pidfile
        proj.find_me()

        return proj
示例#11
0
文件: webapp.py 项目: gitmob/pitz
def pitz_webapp():

    """
    This function gets run by the command-line script pitz-webapp.
    """

    p = setup_options()

    p.add_option('-p', '--port', help='HTTP port (default is 9876)',
       type='int', action='store', default=9876)

    options, args = p.parse_args()
    pitz.setup_logging(getattr(logging, options.log_level))

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    app = webapp.SimpleWSGIApp(proj)

    # Remember that the order that you add handlers matters.  When a
    # request arrives, the app starts with the first handler added and
    # asks it if wants to handle that request.  So, the default handler
    # (if you make one) belongs at the end.

    # Consider this section below the same as the urls.py file in
    # django.

    static_files = os.path.join(os.path.split(
        os.path.dirname(__file__))[0], 'static')

    app.handlers.append(handlers.FaviconHandler(static_files))
    app.handlers.append(handlers.StaticHandler(static_files))
    app.handlers.append(handlers.HelpHandler(proj))
    app.handlers.append(handlers.Update(proj))
    app.handlers.append(handlers.ByFragHandler(proj))
    app.handlers.append(handlers.EditAttributes(proj))
    app.handlers.append(handlers.Project(proj))
    app.handlers.append(handlers.Team(proj))

    httpd = make_server('', options.port, app)
    print "Serving on port %d..." % options.port
    httpd.serve_forever()
示例#12
0
文件: __init__.py 项目: nstinus/pitz
def pitz_html():
    """
    Write out a bunch of HTML files.
    """

    with clepy.spinning_distraction():

        p = setup_options()
        p.set_usage('%prog [options] directory')
        p.add_option('--force',
            help='Ignore timestamps and regenerate all files',
            action='store_true',
            default=False)

        options, args = p.parse_args()

        if options.version:
            print_version()
            return

        if not args:
            p.print_usage()
            sys.exit()

        pitzdir = Project.find_pitzdir(options.pitzdir)

        proj = Project.from_pitzdir(pitzdir)
        proj.find_me()

        htmldir = args[0]

        proj.to_html(htmldir)

        proj.todo.to_html(htmldir)
        proj.milestones.to_html(htmldir)
        proj.tasks.to_html(htmldir)
        proj.components.to_html(htmldir)

        print("Wrote %d html files out of %d entities in project."
            % (
                len([e for e in proj
                    if e.to_html_file(htmldir, options.force)]),
                len(proj)))

        # Record that we rebuilt all the HTML files.
        proj.save_entities_to_yaml_files()
示例#13
0
    def test_stale_pickle(self):
        """
        Verify we use the yaml files when the pickle is too old.
        """

        stat = os.stat('/tmp/project.pickle')

        os.utime('/tmp/project.pickle',
            (stat.st_atime-1, stat.st_mtime-1))

        print("pickle file: %s"
            % os.stat('/tmp/project.pickle').st_mtime)

        print("newest yaml file: %s"
            % max([os.stat(f).st_mtime for f in glob.glob('/tmp/*.yaml')]))

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from
示例#14
0
文件: __init__.py 项目: nstinus/pitz
def pitz_add_estimate():

    p = setup_options()
    p.add_option('-t', '--title', help='Estimate title')

    p.add_option('--from-builtin-estimates',
        action='store_true',
        help='Choose from estimates I already made')

    options, args = p.parse_args()

    if options.version:
        print_version()
        raise SystemExit

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    if options.from_builtin_estimates:

        print("Right now, you got %d estimates in your project."
            % (proj.estimates.length))

        range = Estimate.choose_estimate_range()
        if range:
            print("Adding...")
            Estimate.add_range_of_estimates_to_project(proj, range)
            proj.save_entities_to_yaml_files()

        raise SystemExit

    est = Estimate(
        proj,
        title=options.title or raw_input("Estimate title: ").strip(),
        description=clepy.edit_with_editor('# Estimate description goes here'),
        points=int(raw_input("Points: ").strip()),
    )

    proj.append(est)
    print("Added %s to the project." % est.summarized_view)
    proj.save_entities_to_yaml_files()
示例#15
0
文件: __init__.py 项目: nstinus/pitz
def pitz_shell():
    """
    Start an ipython session after loading in a project.
    """

    p = setup_options()

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    pidfile = write_pidfile_or_die(pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj._shell_mode = True
    proj.find_me()

    # Everything in this dictionary will be added to the top-level
    # namespace in the shell.
    ns = dict([(C.__name__, C) for C in proj.classes.values()])
    ns['p'] = proj
    ns['send_through_pager'] = clepy.send_through_pager
    ns['edit_with_editor'] = clepy.edit_with_editor

    from IPython.Shell import IPShellEmbed
    s = IPShellEmbed(['-colors', 'Linux'])
    s(local_ns=ns)

    # This stuff happens when you close the IPython session.
    answer = raw_input("Write out updated yaml files? ([y]/n) ").strip()
    if answer.lower() not in ['n', 'no']:
        proj.to_yaml_file()
        proj.to_pickle()
        proj.save_entities_to_yaml_files()

    # Remove the pidfile.
    os.remove(pidfile)
示例#16
0
文件: __init__.py 项目: nstinus/pitz
def pitz_assign_task():
    """
    Add this task to somebody's to-do list
    """

    script_name = 'pitz-assign-task'

    p = setup_options()
    p.set_usage("%prog task [person]")

    options, args = p.parse_args()

    if not args:
        p.print_usage()
        return

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    t = proj[args[0]]

    if len(args) == 2:
        person = proj[args[1]]

    else:
        person = Person.choose_from_already_instantiated()

        if not person:
            print("Pick somebody!")
            return

    t.assign(person)
    proj.save_entities_to_yaml_files()
示例#17
0
文件: __init__.py 项目: nstinus/pitz
def pitz_me():
    """
    Pick a Person or make a new one, then save a me.yaml file.
    """

    p = setup_options()

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    if proj.me:
        print("You are %(title)s." % proj.me)
        print("Delete this file if you want to be somebody else:")
        print(os.path.join(proj.pathname, 'me.yaml'))
        return

    if Person.already_instantiated:
        print("You may already be in pitz:")
        choice = Person.choose_from_already_instantiated()
        if choice:
            person = choice
            person.save_as_me_yaml()

            print("OK, I'll recognize you as %(title)s from now on."
                % person)

            return

    print("I'll add you to pitz.")
    pitz_add_person()