Example #1
0
    def focus_changed(self, recent_focus, current_focus):
        self.connect_photoshop()

        if current_focus == None:
            self.save_recent_list = self.update_photoshop_grps()

        else:
            self.save_current_list = self.update_photoshop_grps()

        try:
            if self.save_recent_list != self.save_current_list:
                self.update_photoshop_grps(refresh=True)
                self.save_recent_list = self.save_current_list

        except:
            pass

        try:
            ps_name = self.ps_app.ActiveDocument.name
            ps_path = self.ps_app.ActiveDocument.path
            ps_location = '{0}{1}'.format(ps_path, ps_name)

            ps_location = ps_location.replace("\\", '/')

            if current_focus == None:
                self.save_recent_ps = ps_location
                self.save_recent_groups = utilities.load_json_file(
                    GROUPS_LOCATION)

            else:
                self.save_current_ps = ps_location
                self.save_current_groups = utilities.load_json_file(
                    GROUPS_LOCATION)

        except:
            pass

        try:

            if self.save_recent_ps != self.save_current_ps:
                self.update_table()
                self.save_recent_ps = self.save_current_ps

            if self.save_recent_groups != self.save_current_groups:
                self.update_table()
                self.save_recent_groups = self.save_current_groups

        except:
            pass
Example #2
0
    def load_projects(self):
        try:
            project_startup = utilities.load_json_file(STARTUP_LOCATION)
            utilities.window_stay_on_top(project_startup['window_stay_on_top'],
                                         self.main_ui)
            self.window_stay_on_top_action.setChecked(
                project_startup['window_stay_on_top'])

        except:
            pass

        if os.path.exists(DATA_PATH):
            for data_file in os.listdir(DATA_PATH):
                try:
                    data = data_file.split('.')[-1]

                    if data == 'project':
                        project_name = data_file.split('.')[:-1][0]
                        utilities.add_remove_combo(self.project_combo,
                                                   add=True,
                                                   data=project_name)

                except:
                    pass

        if os.path.exists(STARTUP_LOCATION):
            try:
                project_number = utilities.search_combo_items(
                    self.project_combo, project_startup['main_project'])
                self.project_combo.setCurrentIndex(project_number)

            except:
                pass

        self.set_project_dir()
Example #3
0
    def update_photoshop_grps( self, refresh = False ):
        export_grps = []
        export_list = utilities.load_json_file( GROUPS_LOCATION )

        if refresh:
            self.group_table.setRowCount( 0 )

        try:
            layer_grps = self.ps_app.ActiveDocument.LayerSets

            self.message_report( error_level = 0,
                                     message = "Exporter successfully connected to Photoshop!" )

            if ( len( layer_grps ) > 0 ):
                for grp in layer_grps:
                    grp_name = grp.Name

                    if ( grp_name in export_list ):
                            export_grps.append( grp_name )

                            if refresh:
                                utilities.add_table_item( self.group_table, [grp_name] )
                                self.update_table()

            else:
                self.message_report( error_level = 1,
                                     message = "Can't find any Photoshop groups!" )

        except:
            self.message_report( error_level = 1,
                                 message = "Make sure there is a Photoshop file is open!" )

        return export_grps
Example #4
0
    def project_cleanup(self):
        if os.path.exists(DATA_PATH):
            for data_file in os.listdir(DATA_PATH):
                try:
                    data = data_file.split('.')[-1]

                    if data == 'project':
                        project_data = utilities.load_json_file(
                            '{0}{1}'.format(DATA_PATH, data_file))

                        project_count = 0

                        for project in project_data['saved_files']:
                            if not os.path.exists(project['photoshop_file']):
                                project_data['saved_files'].pop(project_count)

                                project_count += -1

                            project_count += 1

                        utilities.write_json_file(
                            '{0}{1}'.format(DATA_PATH, data_file),
                            project_data)
                except:
                    pass
Example #5
0
    def load_projects( self ):
        try:
            project_startup = utilities.load_json_file( STARTUP_LOCATION )
            utilities.window_stay_on_top( project_startup['window_stay_on_top'], self.main_ui )
            self.window_stay_on_top_action.setChecked( project_startup['window_stay_on_top'] )

        except:
            pass

        if os.path.exists( DATA_PATH ):
            for data_file in os.listdir( DATA_PATH ):
                try:
                    data = data_file.split( '.' )[-1]

                    if data == 'project':
                        project_name = data_file.split( '.' )[:-1][0]
                        utilities.add_remove_combo( self.project_combo, add = True, data = project_name )

                except:
                    pass

        if os.path.exists( STARTUP_LOCATION ):
            try:
                project_number = utilities.search_combo_items( self.project_combo, project_startup['main_project'] )
                self.project_combo.setCurrentIndex( project_number )

            except:
                pass

        self.set_project_dir()
Example #6
0
    def load_group_list(self):
        if os.path.exists(DATA_PATH):
            group_list = utilities.load_json_file(GROUPS_LOCATION)

            for group in group_list:
                utilities.add_table_item(self.group_list_table,
                                         [group, group_list[group]])
Example #7
0
    def focus_changed( self, recent_focus, current_focus ):
        self.connect_photoshop()

        if current_focus == None:
            self.save_recent_list = self.update_photoshop_grps()

        else:
            self.save_current_list = self.update_photoshop_grps()

        try:
            if self.save_recent_list != self.save_current_list:
                self.update_photoshop_grps( refresh = True )
                self.save_recent_list = self.save_current_list

        except:
            pass

        try:
            ps_name = self.ps_app.ActiveDocument.name
            ps_path = self.ps_app.ActiveDocument.path
            ps_location = '{0}{1}'.format( ps_path, ps_name )

            ps_location = ps_location.replace( "\\", '/' )

            if current_focus == None:
                self.save_recent_ps = ps_location
                self.save_recent_groups = utilities.load_json_file( GROUPS_LOCATION )

            else:
                self.save_current_ps = ps_location
                self.save_current_groups = utilities.load_json_file( GROUPS_LOCATION )

        except:
            pass

        try:

            if self.save_recent_ps != self.save_current_ps:
                self.update_table()
                self.save_recent_ps = self.save_current_ps

            if self.save_recent_groups != self.save_current_groups:
                self.update_table()
                self.save_recent_groups = self.save_current_groups

        except:
            pass
Example #8
0
    def edit_group_list( self ):
        self.group_ui = edit_group_list.Edit_Group_List()
        try:
            project_startup = utilities.load_json_file( STARTUP_LOCATION )
            utilities.window_stay_on_top( project_startup['window_stay_on_top'], self.group_ui )
        except:
            pass

        self.group_ui.show()
Example #9
0
    def get_photoshop_group_data( self, project_path, photoshop_file ):
        load_projects = utilities.load_json_file( project_path )

        for project in load_projects['saved_files']:

            if project['photoshop_file'] == photoshop_file:
                ps_low = project['low']
                ps_high = project['high']

        return ps_low, ps_high
Example #10
0
    def edit_group_list(self):
        self.group_ui = edit_group_list.Edit_Group_List()
        try:
            project_startup = utilities.load_json_file(STARTUP_LOCATION)
            utilities.window_stay_on_top(project_startup['window_stay_on_top'],
                                         self.group_ui)
        except:
            pass

        self.group_ui.show()
Example #11
0
    def get_photoshop_group_data(self, project_path, photoshop_file):
        load_projects = utilities.load_json_file(project_path)

        for project in load_projects['saved_files']:

            if project['photoshop_file'] == photoshop_file:
                ps_low = project['low']
                ps_high = project['high']

        return ps_low, ps_high
Example #12
0
    def add_group ( self ):
        group_name = str( self.groupName_line.text() )
        suffix_name = str( self.groupSuffix_line.text() )

        if group_name != '':
            if suffix_name != '':
                utilities.add_table_item( self.group_list_table, [group_name, suffix_name] )

        group_list = utilities.load_json_file( GROUPS_LOCATION )
        group_list[group_name] = suffix_name

        utilities.write_json_file( GROUPS_LOCATION, group_list )
Example #13
0
    def remove_group ( self ):
        remove_items = utilities.get_selected_table_items( self.group_list_table )


        group_list = utilities.load_json_file( GROUPS_LOCATION )

        for item in remove_items:
            if group_list.has_key( item ):
                del group_list[ item ]

        utilities.write_json_file( GROUPS_LOCATION, group_list )
        utilities.remove_selected_table_row( self.group_list_table )
Example #14
0
    def remove_group(self):
        remove_items = utilities.get_selected_table_items(
            self.group_list_table)

        group_list = utilities.load_json_file(GROUPS_LOCATION)

        for item in remove_items:
            if group_list.has_key(item):
                del group_list[item]

        utilities.write_json_file(GROUPS_LOCATION, group_list)
        utilities.remove_selected_table_row(self.group_list_table)
Example #15
0
    def add_group(self):
        group_name = str(self.groupName_line.text())
        suffix_name = str(self.groupSuffix_line.text())

        if group_name != '':
            if suffix_name != '':
                utilities.add_table_item(self.group_list_table,
                                         [group_name, suffix_name])

        group_list = utilities.load_json_file(GROUPS_LOCATION)
        group_list[group_name] = suffix_name

        utilities.write_json_file(GROUPS_LOCATION, group_list)
Example #16
0
def get_employees(auth, name, filters):
    def evaluate_filters(query):
        for f in filters:
            query = f(query)
        return query

    def is_cache_available(path):
        file_exists = os.path.exists(raw_data_path)
        if file_exists:
            return not isFileStale(path)
        else:
            return False

    query = e3s.get_empty_query()
    evaluate_filters(query)

    query_full = {
        'metaType':
        'meta:people-suite:people-api:com.epam.e3s.app.people.api.data.EmployeeEntity',
        'query': json.dumps(query)
    }

    raw_data_path = os.path.join(DATA_PATH, 'rawdata_%s.json' % name)

    if not is_cache_available(raw_data_path):
        print(
            "No local data cache (%s) found (or outdated), getting data from service..."
            % raw_data_path)
        result = e3s.execute_query(query_full, auth)
        empdata = EmployeeData(data=result)
        empdata.save_as_json(raw_data_path)
    else:
        print("Local data cache (%s) found, reading..." % raw_data_path)
        result = load_json_file(raw_data_path)
        empdata = EmployeeData(data=result)

    empdata.save_as_sqlite(name)

    print("Total number of employees: %d" % result["total"])
    return empdata.data_frame
Example #17
0
    def project_cleanup( self ):
        if os.path.exists( DATA_PATH ):
            for data_file in os.listdir( DATA_PATH ):
                try:
                    data = data_file.split( '.' )[-1]

                    if data == 'project':
                        project_data = utilities.load_json_file( '{0}{1}'.format( DATA_PATH, data_file ) )

                        project_count = 0

                        for project in project_data['saved_files']:
                            if not os.path.exists( project['photoshop_file'] ):
                                project_data['saved_files'].pop( project_count )

                                project_count += -1

                            project_count += 1

                        utilities.write_json_file( '{0}{1}'.format( DATA_PATH, data_file ), project_data )
                except:
                    pass
Example #18
0
    def update_photoshop_grps(self, refresh=False):
        export_grps = []
        export_list = utilities.load_json_file(GROUPS_LOCATION)

        if refresh:
            self.group_table.setRowCount(0)

        try:
            layer_grps = self.ps_app.ActiveDocument.LayerSets

            self.message_report(
                error_level=0,
                message="Exporter successfully connected to Photoshop!")

            if (len(layer_grps) > 0):
                for grp in layer_grps:
                    grp_name = grp.Name

                    if (grp_name in export_list):
                        export_grps.append(grp_name)

                        if refresh:
                            utilities.add_table_item(self.group_table,
                                                     [grp_name])
                            self.update_table()

            else:
                self.message_report(error_level=1,
                                    message="Can't find any Photoshop groups!")

        except:
            self.message_report(
                error_level=1,
                message="Make sure there is a Photoshop file is open!")

        return export_grps
Example #19
0
    def export( self ):
        '''Export directory'''
        export_dir = str( self.dir_line.text() )

        '''Get export list'''
        selected_row = self.group_table.selectionModel().selectedRows()

        if selected_row == []:
            for i in xrange( self.group_table.rowCount() ):
                selected_row.append( i )

        group_data = self.get_group_table_data( selected_row )
        group_list = utilities.load_json_file( GROUPS_LOCATION )

        '''Photoshop data'''
        all_grps = self.ps_app.ActiveDocument.LayerSets

        try:
            ps_path = self.ps_app.ActiveDocument.path
            ps_path = ps_path.replace( "\\", '/' )
            ps_name = self.ps_app.ActiveDocument.name

        except:
            group_data = {}
            self.message_report( error_level = 2,
                                 message = "Can't find current Photoshop Directory. Make Sure to save the current Photoshop file!" )

        if group_data != {}:
            if ( len( all_grps ) > 0 ):
                if os.path.exists( export_dir ):

                    '''Saves all layers and visible presets'''
                    layer_visible_dictionary = self.save_layer_visibility()

                    '''Export each group in list'''
                    for group_size in group_data:
                        for group_name in group_data[group_size]:
                            if group_data[group_size][group_name][0] != None:
                                width = group_data[group_size][group_name][0]
                                height = group_data[group_size][group_name][1]

                                for grp in all_grps:
                                    if grp.Name.lower() == group_name:
                                        grp.Visible = True

                                        '''Create file name'''
                                        file_name = '{0}{1}_{2}{3}.tga'.format( export_dir, ps_name.split( '.' )[0], group_size, group_list[group_name] )

                                        '''Save photoshop scene history'''
                                        saved_state = self.ps_app.ActiveDocument.activeHistoryState

                                        '''Edit layer'''
                                        self.ps_app.ActiveDocument.flatten
                                        self.ps_app.ActiveDocument.ResizeImage ( width, height, 72 )
                                        self.ps_app.ActiveDocument.activeLayer.Copy

                                        '''Save layer'''
                                        self.ps_app.ActiveDocument.SaveAs( file_name, Options = self.options )

                                        '''Load photoshop scene history'''
                                        self.ps_app.ActiveDocument.ActiveHistoryState = saved_state
                                        self.ps_app.ActiveDocument.Paste

                                        grp.Visible = False

                    self.load_layer_visibility( layer_visible_dictionary )
                    self.save_export_data( group_data, ps_path, ps_name )
Example #20
0
    def save_export_data( self, group_data, ps_path, ps_name ):
        project_name = str( self.project_combo.currentText() )

        ps_location = '{0}{1}'.format( ps_path, ps_name )

        group_data['photoshop_file'] = ps_location

        load_projects = utilities.load_json_file( '{0}{1}.project'.format( DATA_PATH, project_name ) )
        null_file = False

        if load_projects['saved_files'] == []:
            load_projects['saved_files'] = [group_data]
            null_file = True

        for project in load_projects['saved_files']:
            if project == None:
                load_projects['saved_files'] = [group_data]
                null_file = True

            else:
                try:
                    if project['photoshop_file'] == ps_location:
                        update_low_groups = set( project['low'] ).intersection( group_data['low'] )
                        update_high_groups = set( project['high'] ).intersection( group_data['high'] )

                        new_low_grps = list( set( group_data['low'] ) - set( project['low'] ) )
                        new_high_grps = list( set( group_data['high'] ) - set( project['high'] ) )

                        for low_goup in update_low_groups:
                            project['low'][low_goup] = group_data['low'][low_goup]

                        for high_goup in update_high_groups:
                            project['high'][high_goup] = group_data['high'][high_goup]

                        for grp in new_low_grps:
                            project['low'].update( {grp: group_data['low'][grp]} )

                        for grp in new_high_grps:
                            project['high'].update( {grp: group_data['high'][grp]} )

                except:
                    pass


        new_project = False

        for project in load_projects['saved_files']:
            if not null_file:
                new_project = list( set( [group_data['photoshop_file']] ) - set( [project['photoshop_file']] ) )

                if new_project == []:
                    new_project = False
                    break

        if new_project != False:
            load_projects['saved_files'].append( group_data )


        utilities.write_json_file( '{0}{1}.project'.format( DATA_PATH, project_name ), load_projects )

        save_current_ps = utilities.yes_no_dialog( self, 'Save Photoshop Files', 'Would you like to save your current Photoshop file {0}{1}?'.format( ps_path, ps_name ) )

        if save_current_ps:
            self.save_photoshop_file( ps_path, ps_name )

        self.message_report( error_level = 0,
                                     message = "Export completed!" )
Example #21
0
    def load_group_list( self ):
        if os.path.exists( DATA_PATH ):
            group_list = utilities.load_json_file( GROUPS_LOCATION )

            for group in group_list:
                utilities.add_table_item( self.group_list_table, [group, group_list[group]] )
Example #22
0
    def export(self):
        '''Export directory'''
        export_dir = str(self.dir_line.text())
        '''Get export list'''
        selected_row = self.group_table.selectionModel().selectedRows()

        if selected_row == []:
            for i in xrange(self.group_table.rowCount()):
                selected_row.append(i)

        group_data = self.get_group_table_data(selected_row)
        group_list = utilities.load_json_file(GROUPS_LOCATION)
        '''Photoshop data'''
        all_grps = self.ps_app.ActiveDocument.LayerSets

        try:
            ps_path = self.ps_app.ActiveDocument.path
            ps_path = ps_path.replace("\\", '/')
            ps_name = self.ps_app.ActiveDocument.name

        except:
            group_data = {}
            self.message_report(
                error_level=2,
                message=
                "Can't find current Photoshop Directory. Make Sure to save the current Photoshop file!"
            )

        if group_data != {}:
            if (len(all_grps) > 0):
                if os.path.exists(export_dir):
                    '''Saves all layers and visible presets'''
                    layer_visible_dictionary = self.save_layer_visibility()
                    '''Export each group in list'''
                    for group_size in group_data:
                        for group_name in group_data[group_size]:
                            if group_data[group_size][group_name][0] != None:
                                width = group_data[group_size][group_name][0]
                                height = group_data[group_size][group_name][1]

                                for grp in all_grps:
                                    if grp.Name.lower() == group_name:
                                        grp.Visible = True
                                        '''Create file name'''
                                        file_name = '{0}{1}_{2}{3}.tga'.format(
                                            export_dir,
                                            ps_name.split('.')[0], group_size,
                                            group_list[group_name])
                                        '''Save photoshop scene history'''
                                        saved_state = self.ps_app.ActiveDocument.activeHistoryState
                                        '''Edit layer'''
                                        self.ps_app.ActiveDocument.flatten
                                        self.ps_app.ActiveDocument.ResizeImage(
                                            width, height, 72)
                                        self.ps_app.ActiveDocument.activeLayer.Copy
                                        '''Save layer'''
                                        self.ps_app.ActiveDocument.SaveAs(
                                            file_name, Options=self.options)
                                        '''Load photoshop scene history'''
                                        self.ps_app.ActiveDocument.ActiveHistoryState = saved_state
                                        self.ps_app.ActiveDocument.Paste

                                        grp.Visible = False

                    self.load_layer_visibility(layer_visible_dictionary)
                    self.save_export_data(group_data, ps_path, ps_name)
Example #23
0
    def save_export_data(self, group_data, ps_path, ps_name):
        project_name = str(self.project_combo.currentText())

        ps_location = '{0}{1}'.format(ps_path, ps_name)

        group_data['photoshop_file'] = ps_location

        load_projects = utilities.load_json_file('{0}{1}.project'.format(
            DATA_PATH, project_name))
        null_file = False

        if load_projects['saved_files'] == []:
            load_projects['saved_files'] = [group_data]
            null_file = True

        for project in load_projects['saved_files']:
            if project == None:
                load_projects['saved_files'] = [group_data]
                null_file = True

            else:
                try:
                    if project['photoshop_file'] == ps_location:
                        update_low_groups = set(project['low']).intersection(
                            group_data['low'])
                        update_high_groups = set(project['high']).intersection(
                            group_data['high'])

                        new_low_grps = list(
                            set(group_data['low']) - set(project['low']))
                        new_high_grps = list(
                            set(group_data['high']) - set(project['high']))

                        for low_goup in update_low_groups:
                            project['low'][low_goup] = group_data['low'][
                                low_goup]

                        for high_goup in update_high_groups:
                            project['high'][high_goup] = group_data['high'][
                                high_goup]

                        for grp in new_low_grps:
                            project['low'].update(
                                {grp: group_data['low'][grp]})

                        for grp in new_high_grps:
                            project['high'].update(
                                {grp: group_data['high'][grp]})

                except:
                    pass

        new_project = False

        for project in load_projects['saved_files']:
            if not null_file:
                new_project = list(
                    set([group_data['photoshop_file']]) -
                    set([project['photoshop_file']]))

                if new_project == []:
                    new_project = False
                    break

        if new_project != False:
            load_projects['saved_files'].append(group_data)

        utilities.write_json_file(
            '{0}{1}.project'.format(DATA_PATH, project_name), load_projects)

        save_current_ps = utilities.yes_no_dialog(
            self, 'Save Photoshop Files',
            'Would you like to save your current Photoshop file {0}{1}?'.
            format(ps_path, ps_name))

        if save_current_ps:
            self.save_photoshop_file(ps_path, ps_name)

        self.message_report(error_level=0, message="Export completed!")
Example #24
0
def get_auth_data():
    config = load_json_file("password.cfg")

    user = config["service"]["user"]
    pas = config["service"]["pass"]
    return (user, pas)