| 44 | | def __init__(self, socket, codeFilePath): |
|---|
| 45 | | for name, msgPart in ( |
|---|
| 46 | | ('socket', 'UNIX socket'), ('codeFilePath', 'code file')): |
|---|
| 47 | | #------------------------------------------------------- |
|---|
| 48 | | path = locals()[name] |
|---|
| 49 | | if not os.path.exists(path): |
|---|
| 50 | | raise RuntimeError( |
|---|
| 51 | | "No %s available at '%s'" % (msgPart, socket)) |
|---|
| 52 | | setattr(self, name, path) |
|---|
| | 44 | def __init__(self, socket, codePath=None, codeString=None): |
|---|
| | 45 | if not os.path.exists(socket): |
|---|
| | 46 | raise RuntimeError("No UNIX socket available at '%s'" % socket) |
|---|
| | 47 | self.socket = socket |
|---|
| | 48 | if codeString is None and codePath is None: |
|---|
| | 49 | raise RuntimeError( |
|---|
| | 50 | "You must specify either a file or a string containing "+\ |
|---|
| | 51 | "Python source for the job.") |
|---|
| | 52 | if codeString is None: |
|---|
| | 53 | if not os.path.exists(codePath): |
|---|
| | 54 | raise RuntimeError("No code file available at '%s'" % codePath) |
|---|
| | 55 | fh = open(codePath) |
|---|
| | 56 | codeString = fh.read() |
|---|
| | 57 | fh.close() |
|---|
| | 58 | self.jobCode = textwrap.dedent(codeString) |
|---|