Monero
Loading...
Searching...
No Matches
upload Namespace Reference

Classes

class  ClientLoginError
class  AbstractRpcServer
class  HttpRpcServer
 elif e.code >= 500 and e.code < 600: More...
class  VersionControlSystem
class  SubversionVCS
class  GitVCS
class  MercurialVCS

Functions

 GetEmail (prompt)
 StatusUpdate (msg)
 ErrorExit (msg)
 GetRpcServer (options)
 EncodeMultipartFormData (fields, files)
 GetContentType (filename)
 RunShellWithReturnCode (command, print_output=False, universal_newlines=True)
 RunShell (command, silent_ok=False, universal_newlines=True, print_output=False)
 SplitPatch (data)
 UploadSeparatePatches (issue, rpc_server, patchset, data, options)
 GuessVCS (options)
 RealMain (argv, data=None)
 main ()

Variables

int verbosity = 1
int MAX_UPLOAD_SIZE = 900 * 1024
 parser = optparse.OptionParser(usage="%prog [options] [-- diff_options]")
 action
 dest
 default
 help
 group = parser.add_option_group("Logging options")
 const
 metavar
 type
 use_shell = sys.platform.startswith("win")

Detailed Description

Tool for uploading diffs from a version control system to the codereview app.

Usage summary: upload.py [options] [-- diff_options]

Diff options are passed to the diff command of the underlying system.

Supported version control systems:
  Git
  Mercurial
  Subversion

It is important for Git/Mercurial users to specify a tree/node/branch to diff
against by using the '--rev' option.

Function Documentation

◆ EncodeMultipartFormData()

upload.EncodeMultipartFormData ( fields,
files )
Encode form fields for multipart/form-data.

Args:
  fields: A sequence of (name, value) elements for regular form fields.
  files: A sequence of (name, filename, value) elements for data to be
         uploaded as files.
Returns:
  (content_type, body) ready for httplib.HTTP instance.

Source:
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306

◆ ErrorExit()

upload.ErrorExit ( msg)
Print an error message to stderr and exit.

◆ GetContentType()

upload.GetContentType ( filename)
Helper to guess the content-type from the filename.

◆ GetEmail()

upload.GetEmail ( prompt)
Prompts the user for their email address and returns it.

The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
for next time we prompt.

◆ GetRpcServer()

upload.GetRpcServer ( options)
Returns an instance of an AbstractRpcServer.

Returns:
  A new AbstractRpcServer, on which RPC calls can be made.

◆ GuessVCS()

upload.GuessVCS ( options)
Helper to guess the version control system.

This examines the current directory, guesses which VersionControlSystem
we're using, and returns an instance of the appropriate class.  Exit with an
error if we can't figure it out.

Returns:
  A VersionControlSystem instance. Exits if the VCS can't be guessed.

◆ main()

upload.main ( void )

◆ RealMain()

upload.RealMain ( argv,
data = None )
The real main function.

Args:
  argv: Command line arguments.
  data: Diff contents. If None (default) the diff is generated by
    the VersionControlSystem implementation returned by GuessVCS().

Returns:
  A 2-tuple (issue id, patchset id).
  The patchset id is None if the base files are not uploaded by this
  script (applies only to SVN checkouts).

◆ RunShell()

upload.RunShell ( command,
silent_ok = False,
universal_newlines = True,
print_output = False )

◆ RunShellWithReturnCode()

upload.RunShellWithReturnCode ( command,
print_output = False,
universal_newlines = True )
Executes a command and returns the output from stdout and the return code.

Args:
  command: Command to execute.
  print_output: If True, the output is printed to stdout.
                If False, both stdout and stderr are ignored.
  universal_newlines: Use universal_newlines flag (default: True).

Returns:
  Tuple (output, return code)

◆ SplitPatch()

upload.SplitPatch ( data)
Splits a patch into separate pieces for each file.

Args:
  data: A string containing the output of svn diff.

Returns:
  A list of 2-tuple (filename, text) where text is the svn diff output
    pertaining to filename.

◆ StatusUpdate()

upload.StatusUpdate ( msg)
Print a status message to stdout.

If 'verbosity' is greater than 0, print the message.

Args:
  msg: The string to print.

◆ UploadSeparatePatches()

upload.UploadSeparatePatches ( issue,
rpc_server,
patchset,
data,
options )
Uploads a separate patch for each file in the diff output.

Returns a list of [patch_key, filename] for each file.

Variable Documentation

◆ action

upload.action

◆ const

upload.const

◆ default

upload.default

◆ dest

upload.dest

◆ group

upload.group = parser.add_option_group("Logging options")

◆ help

upload.help

◆ MAX_UPLOAD_SIZE

int upload.MAX_UPLOAD_SIZE = 900 * 1024

◆ metavar

upload.metavar

◆ parser

upload.parser = optparse.OptionParser(usage="%prog [options] [-- diff_options]")

◆ type

upload.type

◆ use_shell

upload.use_shell = sys.platform.startswith("win")

◆ verbosity

int upload.verbosity = 1