Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
f06d61c6
Commit
f06d61c6
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
thank you jor and GNU Emacs (Esc-X untabify) [remove tabs]
parent
e9bb1a92
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/GnuPGInterface.py
+28
-28
28 additions, 28 deletions
src/common/GnuPGInterface.py
with
28 additions
and
28 deletions
src/common/GnuPGInterface.py
+
28
−
28
View file @
f06d61c6
...
@@ -274,14 +274,14 @@ class GnuPG:
...
@@ -274,14 +274,14 @@ class GnuPG:
self.options = Options()
self.options = Options()
def run(self, gnupg_commands, args=None, create_fhs=None, attach_fhs=None):
def run(self, gnupg_commands, args=None, create_fhs=None, attach_fhs=None):
"""
Calls GnuPG with the list of string commands gnupg_commands,
"""
Calls GnuPG with the list of string commands gnupg_commands,
complete with prefixing dashes.
complete with prefixing dashes.
For example, gnupg_commands could be
For example, gnupg_commands could be
'
[
"
--sign
"
,
"
--encrypt
"
]
'
'
[
"
--sign
"
,
"
--encrypt
"
]
'
Returns a GnuPGInterface.Process object.
Returns a GnuPGInterface.Process object.
args is an optional list of GnuPG command arguments (not options),
args is an optional list of GnuPG command arguments (not options),
such as keyID
'
s to export, filenames to process, etc.
such as keyID
'
s to export, filenames to process, etc.
create_fhs is an optional list of GnuPG filehandle
create_fhs is an optional list of GnuPG filehandle
names that will be set as keys of the returned Process object
'
s
names that will be set as keys of the returned Process object
'
s
...
@@ -307,9 +307,9 @@ class GnuPG:
...
@@ -307,9 +307,9 @@ class GnuPG:
opened file and
'
attach_fhs[stdin] is my_file
'
, then GnuPG
opened file and
'
attach_fhs[stdin] is my_file
'
, then GnuPG
will read its standard input from my_file. This is useful
will read its standard input from my_file. This is useful
if you want GnuPG to read/write to/from an existing file.
if you want GnuPG to read/write to/from an existing file.
For instance:
For instance:
f = open(
"
encrypted.gpg
"
)
f = open(
"
encrypted.gpg
"
)
gnupg.run([
"
--decrypt
"
], attach_fhs={
'
stdin
'
: f})
gnupg.run([
"
--decrypt
"
], attach_fhs={
'
stdin
'
: f})
Using attach_fhs also helps avoid system buffering
Using attach_fhs also helps avoid system buffering
...
@@ -317,29 +317,29 @@ class GnuPG:
...
@@ -317,29 +317,29 @@ class GnuPG:
can cause the process to deadlock.
can cause the process to deadlock.
If not mentioned in create_fhs or attach_fhs,
If not mentioned in create_fhs or attach_fhs,
GnuPG filehandles which are a std* (stdin, stdout, stderr)
GnuPG filehandles which are a std* (stdin, stdout, stderr)
are defaulted to the running process
'
version of handle.
are defaulted to the running process
'
version of handle.
Otherwise, that type of handle is simply not used when calling GnuPG.
Otherwise, that type of handle is simply not used when calling GnuPG.
For example, if you do not care about getting data from GnuPG
'
s
For example, if you do not care about getting data from GnuPG
'
s
status filehandle, simply do not specify it.
status filehandle, simply do not specify it.
run() returns a Process() object which has a
'
handles
'
run() returns a Process() object which has a
'
handles
'
which is a dictionary mapping from the handle name
which is a dictionary mapping from the handle name
(such as
'
stdin
'
or
'
stdout
'
) to the respective
(such as
'
stdin
'
or
'
stdout
'
) to the respective
newly-created FileObject connected to the running GnuPG process.
newly-created FileObject connected to the running GnuPG process.
For instance, if the call was
For instance, if the call was
process = gnupg.run([
"
--decrypt
"
], stdin=1)
process = gnupg.run([
"
--decrypt
"
], stdin=1)
after run returns
'
process.handles[
"
stdin
"
]
'
after run returns
'
process.handles[
"
stdin
"
]
'
is a FileObject connected to GnuPG
'
s standard input,
is a FileObject connected to GnuPG
'
s standard input,
and can be written to.
and can be written to.
"""
"""
if args == None: args = []
if args == None: args = []
if create_fhs == None: create_fhs = []
if create_fhs == None: create_fhs = []
if attach_fhs == None: attach_fhs = {}
if attach_fhs == None: attach_fhs = {}
for std in _stds:
for std in _stds:
if not attach_fhs.has_key(std)
\
if not attach_fhs.has_key(std)
\
and std not in create_fhs:
and std not in create_fhs:
...
@@ -367,9 +367,9 @@ class GnuPG:
...
@@ -367,9 +367,9 @@ class GnuPG:
def _attach_fork_exec(self, gnupg_commands, args, create_fhs, attach_fhs):
def _attach_fork_exec(self, gnupg_commands, args, create_fhs, attach_fhs):
"""
This is like run(), but without the passphrase-helping
"""
This is like run(), but without the passphrase-helping
(note that run() calls this).
"""
(note that run() calls this).
"""
process = Process()
process = Process()
for fh_name in create_fhs + attach_fhs.keys():
for fh_name in create_fhs + attach_fhs.keys():
if not _fd_modes.has_key(fh_name):
if not _fd_modes.has_key(fh_name):
...
@@ -557,12 +557,12 @@ class Options:
...
@@ -557,12 +557,12 @@ class Options:
self
.
extra_args
=
[]
self
.
extra_args
=
[]
def
get_args
(
self
):
def
get_args
(
self
):
"""
Generate a list of GnuPG arguments based upon attributes.
"""
"""
Generate a list of GnuPG arguments based upon attributes.
"""
return
self
.
get_meta_args
()
+
self
.
get_standard_args
()
+
self
.
extra_args
return
self
.
get_meta_args
()
+
self
.
get_standard_args
()
+
self
.
extra_args
def
get_standard_args
(
self
):
def
get_standard_args
(
self
):
"""
Generate a list of standard, non-meta or extra arguments
"""
"""
Generate a list of standard, non-meta or extra arguments
"""
args
=
[]
args
=
[]
if
self
.
homedir
!=
None
:
args
.
extend
(
[
'
--homedir
'
,
self
.
homedir
]
)
if
self
.
homedir
!=
None
:
args
.
extend
(
[
'
--homedir
'
,
self
.
homedir
]
)
if
self
.
options
!=
None
:
args
.
extend
(
[
'
--options
'
,
self
.
options
]
)
if
self
.
options
!=
None
:
args
.
extend
(
[
'
--options
'
,
self
.
options
]
)
...
@@ -589,7 +589,7 @@ class Options:
...
@@ -589,7 +589,7 @@ class Options:
return
args
return
args
def
get_meta_args
(
self
):
def
get_meta_args
(
self
):
"""
Get a list of generated meta-arguments
"""
"""
Get a list of generated meta-arguments
"""
args
=
[]
args
=
[]
if
self
.
meta_pgp_5_compatible
:
args
.
extend
(
[
'
--compress-algo
'
,
'
1
'
,
if
self
.
meta_pgp_5_compatible
:
args
.
extend
(
[
'
--compress-algo
'
,
'
1
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment