Properly make a random activity_id outside Sugar.

This commit is contained in:
Sebastian Silva 2016-05-17 03:50:09 -05:00
parent c5fa4dfd59
commit a462f14c55

View File

@ -40,6 +40,9 @@ from sugar3 import logger
from sugar3.bundle.bundle import MalformedBundleException from sugar3.bundle.bundle import MalformedBundleException
from distutils.dir_util import mkpath from distutils.dir_util import mkpath
import time
import hashlib
import random
def create_activity_instance(constructor, handle): def create_activity_instance(constructor, handle):
activity = constructor(handle) activity = constructor(handle)
@ -165,7 +168,10 @@ def main():
activity_constructor = getattr(module, class_name) activity_constructor = getattr(module, class_name)
if not options.activity_id: if not options.activity_id:
options.activity_id = bundle.get_name() # Generate random hash
data = '%s%s' % (time.time(), random.randint(10000, 100000))
random_hash = hashlib.sha1(data).hexdigest()
options.activity_id = random_hash
options.bundle_id = bundle.get_bundle_id() options.bundle_id = bundle.get_bundle_id()
activity_handle = activityhandle.ActivityHandle( activity_handle = activityhandle.ActivityHandle(