~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/fileservice_lib/action.py

  • Committer: mattgiuca
  • Date: 2008-07-15 09:18:02 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:877
pulldown_subj/__init__.py: Added "enrol_user" function which pulls down a user
    and also enrols them in the database.
Added script enrolallusers.py which scriptulously performs automatic
enrolments of all users in the system, similar to remakeallusers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
#       path:   The [repository] path to the file or directory to be
111
111
#               checked out.
112
112
113
 
# action=svnrepomkdir: Create a directory in a repository (not WC).
114
 
#       path:   The path to the directory to be created (under the IVLE
115
 
#               repository base).
116
 
#       logmsg: Text of the log message.
117
 
118
 
# action=svnrepostat: Check if a path exists in a repository (not WC).
119
 
#       path:   The path to the directory to be checked (under the IVLE
120
 
#               repository base).
121
 
#
122
113
# TODO: Implement the following actions:
123
114
#   svnupdate (done?)
124
115
# TODO: Implement ZIP unpacking in putfiles (done?).
265
256
 
266
257
### ACTIONS ###
267
258
 
268
 
def action_delete(req, fields):
 
259
def action_remove(req, fields):
 
260
    # TODO: Do an SVN rm if the file is versioned.
269
261
    # TODO: Disallow removal of student's home directory
270
262
    """Removes a list of files or directories.
271
263
 
549
541
    except pysvn.ClientError, e:
550
542
        raise ActionError(str(e))
551
543
 
552
 
def action_svnremove(req, fields):
553
 
    """Performs a "svn remove" on each file specified.
554
 
 
555
 
    Reads fields: 'path' (multiple)
556
 
    """
557
 
    paths = fields.getlist('path')
558
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
559
 
 
560
 
    try:
561
 
        svnclient.remove(paths, force=True)
562
 
    except pysvn.ClientError, e:
563
 
        raise ActionError(str(e))
564
 
 
565
544
def action_svnupdate(req, fields):
566
545
    """Performs a "svn update" to each file specified.
567
546
 
577
556
    except pysvn.ClientError, e:
578
557
        raise ActionError(str(e))
579
558
 
580
 
def action_svnresolved(req, fields):
581
 
    """Performs a "svn resolved" to each file specified.
582
 
 
583
 
    Reads fields: 'path'
584
 
    """
585
 
    path = fields.getfirst('path')
586
 
    if path is None:
587
 
        raise ActionError("Required field missing")
588
 
    path = actionpath_to_local(req, path)
589
 
 
590
 
    try:
591
 
        svnclient.resolved(path, recurse=True)
592
 
    except pysvn.ClientError, e:
593
 
        raise ActionError(str(e))
594
 
 
595
559
def action_svnrevert(req, fields):
596
560
    """Performs a "svn revert" to each file specified.
597
561
 
661
625
        raise ActionError(str(e))
662
626
 
663
627
def action_svncheckout(req, fields):
664
 
    """Performs a "svn checkout" of the first path into the second path.
 
628
    """Performs a "svn checkout" of each path specified.
665
629
 
666
630
    Reads fields: 'path'    (multiple)
667
631
    """
668
632
    paths = fields.getlist('path')
669
633
    if len(paths) != 2:
670
634
        raise ActionError("usage: svncheckout url local-path")
671
 
    url = conf.svn_addr + "/" + paths[0]
 
635
    url = conf.svn_addr + "/" + login + "/" + paths[0]
672
636
    local_path = actionpath_to_local(req, str(paths[1]))
673
637
    try:
674
638
        svnclient.callback_get_login = get_login
676
640
    except pysvn.ClientError, e:
677
641
        raise ActionError(str(e))
678
642
 
679
 
def action_svnrepomkdir(req, fields):
680
 
    """Performs a "svn mkdir" on a path under the IVLE SVN root.
681
 
 
682
 
    Reads fields: 'path'
683
 
    """
684
 
    path = fields.getfirst('path')
685
 
    logmsg = fields.getfirst('logmsg')
686
 
    url = conf.svn_addr + "/" + path
687
 
    try:
688
 
        svnclient.callback_get_login = get_login
689
 
        svnclient.mkdir(url, log_message=logmsg)
690
 
    except pysvn.ClientError, e:
691
 
        raise ActionError(str(e))
692
 
 
693
 
def action_svnrepostat(req, fields):
694
 
    """Discovers whether a path exists in a repo under the IVLE SVN root.
695
 
 
696
 
    Reads fields: 'path'
697
 
    """
698
 
    path = fields.getfirst('path')
699
 
    url = conf.svn_addr + "/" + path
700
 
    svnclient.exception_style = 1 
701
 
 
702
 
    try:
703
 
        svnclient.callback_get_login = get_login
704
 
        svnclient.info2(url)
705
 
    except pysvn.ClientError, e:
706
 
        # Error code 170000 means ENOENT in this revision.
707
 
        if e[1][0][1] == 170000:
708
 
            raise util.IVLEError(404, 'The specified repository path does not exist')
709
 
        else:
710
 
            raise ActionError(str(e[0]))
711
 
 
712
643
# Table of all action functions #
713
644
# Each function has the interface f(req, fields).
714
645
 
715
646
actions_table = {
716
 
    "delete" : action_delete,
 
647
    "remove" : action_remove,
717
648
    "move" : action_move,
718
649
    "mkdir" : action_mkdir,
719
650
    "putfile" : action_putfile,
723
654
    "unpublish" : action_unpublish,
724
655
 
725
656
    "svnadd" : action_svnadd,
726
 
    "svnremove" : action_svnremove,
727
657
    "svnupdate" : action_svnupdate,
728
 
    "svnresolved" : action_svnresolved,
729
658
    "svnrevert" : action_svnrevert,
730
659
    "svnpublish" : action_svnpublish,
731
660
    "svnunpublish" : action_svnunpublish,
732
661
    "svncommit" : action_svncommit,
733
662
    "svncheckout" : action_svncheckout,
734
 
    "svnrepomkdir" : action_svnrepomkdir,
735
 
    "svnrepostat" : action_svnrepostat,
736
663
}