Skip to content

Commit

Permalink
* The last-update-time attribute in permissions.json is now optional.…
Browse files Browse the repository at this point in the history
… You can easilly mark a program as needing to be

 updated with the command "subuser mark-as-needing-update program-name"
  • Loading branch information
timthelion committed Feb 15, 2014
1 parent b1d7f2b commit d230c69
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
VERSION 0.2
-------------

* The last-update-time attribute in permissions.json is now optional. You can easilly mark a program as needing to be updated with the command "subuser mark-as-needing-update program-name"

* Can now set a container as privileged within the permissions.json file.

* Added module: utils.py
Expand Down
26 changes: 26 additions & 0 deletions logic/subuserCommands/mark-as-needing-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# This file should be compatible with both Python 2 and 3.
# If it is not, please file a bug report.
import sys
import subuserlib.installTime
import subuserlib.permissions
import subuserlib.availablePrograms

def printHelp():
print("""
Mark a program as needing to be updated. Note, that this may mess up the formatting of it's permissions.json file.
Usage:
$ subuser mark-as-needing-update program-name
""")

if (not len(sys.argv) == 2) or sys.argv[1] == "help" or sys.argv[1] == "--help" or sys.argv[1] == "-h":
printHelp()

elif not subuserlib.availablePrograms.available(sys.argv[1]):
print(sys.argv[1] + " is not the name of any known program. Cannot mark it as having an update.")
else:
programName = sys.argv[1]
permissions = subuserlib.permissions.getPermissions(programName)
permissions["last-update-time"] = subuserlib.installTime.currentTimeString()
subuserlib.permissions.setPermissions(programName,permissions)
9 changes: 9 additions & 0 deletions logic/subuserCommands/subuserlib/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ def getPermissions(programName):
permissionsFile.close()
return permissions

def setPermissions(programName,permissions):
""" Set the permissions of a given program.
Warning, will mess up the formatting of the json file.
"""
permissionsFilePath = paths.getPermissionsFilePath(programName)
permissionsFile = open(permissionsFilePath,"w")
json.dump(permissions,permissionsFile,indent=1, separators=(',', ': '))
permissionsFile.close()

def hasExecutable(programName):
""" Return True if the program has an executable associated with it. """
try:
Expand Down

0 comments on commit d230c69

Please sign in to comment.